Results 1 to 2 of 2

Thread: Too many SQLs issued by hibernate while runing thru spring

  1. #1
    Join Date
    Aug 2004
    Posts
    109

    Default 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.
    Thanks,
    Alex.

  2. #2
    Join Date
    Aug 2004
    Posts
    109

    Default

    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 :-)
    Thanks,
    Alex.

Similar Threads

  1. Replies: 5
    Last Post: Feb 3rd, 2009, 05:19 AM
  2. Replies: 3
    Last Post: Aug 16th, 2007, 12:10 PM
  3. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 7
    Last Post: Aug 21st, 2004, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •