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