-->
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.  [ 2 posts ] 
Author Message
 Post subject: LazyLoadingException on methods not related to mapped data.
PostPosted: Wed Dec 07, 2005 1:08 pm 
Newbie

Joined: Wed Dec 07, 2005 12:51 pm
Posts: 2
We're using Hibnernate 3.0.5 on a major project in multiple tiers (Weblogic on the Application Server side, Tomcat as the web server).

In the web tier, I'm getting LazyInitializationExceptions calling methods that have nothing to do with the mapped data. I boiled a class down to the simplest example I can come up with:

Code:
public class Foo
{
  protected long id;  // Mapped to a long field

// .. getter and setters for id

// bar is not mapped in any way.
  public String getBar()
  {
     return "bar";  // about as plain a method as you can get.
   }

   public String toString()
   {
     return "to string";
   }
}


When I call the getBar() method on an instance of Foo in Tomcat, I get the LazyInitializationException, even though I don't map "bar" in any way, shape or form.

Just for fun, I added the toString() method above and get the LazyInitializationException as well.

Debugging reveals that the CGLib stuff is trying to find a proxy for these methods.

Does anyone else think this behavior is not desired? If I have methods in my class that do not deal with the mapped data, I should be able to call the regardless. Is there a way to circumvent the CGLib stuff for methods that do not relate to mapped fields.

Thanks,
Mike


Top
 Profile  
 
 Post subject: Use final
PostPosted: Wed Dec 07, 2005 6:18 pm 
Newbie

Joined: Wed Dec 07, 2005 12:51 pm
Posts: 2
Never mind, after digging around I finally came across a posting that says I should use "final" to prevent the proxy sublcass from intercepting the calls.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.