-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Losing my mind. Associations won't be lazy!
PostPosted: Thu Oct 23, 2008 7:27 pm 
Newbie

Joined: Thu Oct 23, 2008 7:06 pm
Posts: 3
Hibernate version: 3.3.1
Hibernate Annotations version: 3.4

Hello,
I've searched the forums and documentation all day. What on earth am I doing wrong. Loading just one object results in 10 SQL queries. It's being caused by my many-to-ones, but they're all set to lazy. I'm all out of ideas. Please help!?


Example of my association mappings:
Code:
   @ManyToOne(cascade = {}, fetch=FetchType.LAZY)
   @NotFound(action = NotFoundAction.IGNORE)
   @JoinColumn(name = "user_id")
   @LazyToOne(LazyToOneOption.PROXY)
   public User getUser()
   {
      return user;
   }



This will result in eager loading (by select) of all my many-to-one's and cascades into eager fetching of their associations as well:
Code:
   session.get(User.class, 1);



Does anybody have any suggestions of what I can try next?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2008 4:33 pm 
Newbie

Joined: Thu Oct 23, 2008 7:06 pm
Posts: 3
So, does the mapping at least look right? In other words, based on what you see here, the association should not trigger another SQL query when loading the object, correct?
If so, can anybody think of other things that could trigger the extra queries (eager fetching)?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2008 5:55 pm 
Newbie

Joined: Thu Oct 23, 2008 7:06 pm
Posts: 3
Not a lot of lazy users here?
Well anyway, the problem seems to be with this this
Code:
@NotFound(action = NotFoundAction.IGNORE)

If I have that in there, then my lazy setting seem to be ignored. If I take it out, then things work as expected. I have not yet researched why, but it's probably documented somewhere. It never occurred to me try taking that option out until I started getting really desperate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.