Announcement Announcement Module
Collapse
No announcement yet.
Too many SQLs issued by hibernate while runing thru spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Too many SQLs issued by hibernate while runing thru spring

    I am trying to figure out why there are so many SQLs when I use HibernateTemplate's find* methods. So, for example:

    Code:
            List l = getHibernateTemplate ().findByNamedQueryAndNamedParam (
                    "findApplicantByUsername",
                    new String [] { "userName" },
                    new Object [] { username });
    Basically, this should find applicant and a few non-lazy/one-to-one collections. So, I should see in my logs approximately 3 SQLs. Applicant however has another 10 associated collections, each of which are declared lazy in hibernate config files. When I run the query above I see about 13 queries, which means that all of my lazy collections are being initialized.

    When I run the following code (no spring):

    Code:
            Session s = sessions.openSession ();
            Query q = s.getNamedQuery ("findApplicantByUsername");
            q.setParameter ("userName", "u7uhicuj");
            List results = q.list ();
            results.get (0);
    It works correctly, no lazy collections are initialized, only 3SQLs are issued.

    What did I mess up? What can I do to revert to the desired lazy behavior?

    Any help is really appreciated!

    PS> I did see couple of posts about the same problem but have not seen any response.

  • #2
    sorry, those statements appear to come from deletion of an object with delete-all-orphaned flag set on, which makes sense.

    so, I withraw the question :-)

    Comment

    Working...
    X