On Nov 2, 2005, at 1:09 AM, Anil Gangolli wrote:
I suspect this is just Hibernate 3.x behavior with cglib proxies
around lazy loading. The times when it works is when the fields have
been loaded already. Using the accessors will always get the fields
initialized properly.
I hadn't thought of that, but you are right, Hibernate3 is a suspect in
this case. Hibernate now uses lazy loading for simple properties and
defaults to lazy="true"
I suspected this problem with that weird intermittent Planet page error:
http://opensource2.atlassian.com/projects/roller/browse/ROL-843
Changing the loading behavior in the mappings to be non-lazy one
should be able to avoid this behavior. If we have a lot of code
dealing with pojo members directly, we may want to do this. I believe
the laziness defaults changed between 2.x and 3.x.
I looked into this. Hibernate3 allows a lazy attribute at the class
level and by default lazy="true". There are two reasons why I couldn't
easily set it to false:
1 - The version of XDoclet we're using doesn't support that (I tried to
upgrade the the latest XDoclet, but ran into an XDoclet bug that
prevented upgrade).
2 - I didn't want to turn off lazy loading at the class level, because
for performance reasons we still want it for collections.
As a quick fix, I bet you could change WeblogEntryData.setData().
Change this line:
this.text = other.text;
To this:
this.text = other.getText();
The more involved fix is to upgrade to the latest XDoclet (which may
require building it from CVS to get around that bug that bit me), set
lazy="false" at the class level and set lazy="true" for the individual
collections that we want to be lazy-loaded (and I think we're already
doing that). We're using XDoclet 1.2b4 and the latest XDoclet is 1.2.
Another possibility is to change all of our POJO setData() methods to
use the getters rather than direct access to fields, but that may not
be a as safe as the lazy="false" fix.
- Dave