[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: lazily initialize collections in their getters

mars1412 do-not-reply at jboss.com
Wed Aug 6 06:37:17 EDT 2008

thanks for the answers

"jaikiran" wrote : Well, that's what the user would expect right? If someone explicitly sets it to null, then he should get back null, isn't it? 

Yes, you are right. In the case of collection initalisation the other approach is more appropriate.

When I think about it, the lazy initalization approach in the getters came from handling embedded components.
As defined by hibernate, the embedded component will be null, if all its elements are null.
so hibernate would set the embedded component to null, if all its fields in the database are null.
that would break code like this:
In this case this initalization would not help:
private EmbeddedComponentTyp embedded = new EmbeddedComponentTyp();

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4168977#4168977

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4168977

More information about the jboss-user mailing list