Sorry about the slow reply... for some reason this message didn't get sent to my email.
>Where a persisted entity contains a collection, such as a List annotated as a OneToMany relationship, should OpenJPA initialise that list? While there is some muddyness in JPA as to when you'll get a null vs when you'll get an empty list, I vote that OpenJPA shouldn't initialize a list. In your getter, I'd add a if(null)list=new ArrayList() to be certain that you don't hit any of these NPEs. > I recently upgraded from OpenJPA 2.0.1 to a nightly snapshot of 2.2.0, and > it seems to have a change in behaviour around uninitialised collections. Good find. It appears that OPENJPA-1770 changed (not regressed) this behavior. I will update the migration considerations section in the user manual. > [1] As an aside, I notice that unlike the comment I refer to here, I'm > adding annotations to the actual attributes, rather than the > getters/setters. For the most part, field vs property(method) level annotations is personal preference. I'm sure someone on this list can come up with some case where property annotations would be better, but I don't have any of those examples. I prefer to annotate fields as I can easily see the mapping information without having to look throughout an entire class. -- View this message in context: http://openjpa.208410.n2.nabble.com/Should-OpenJPA-initialise-empty-collections-tp6926980p6972006.html Sent from the OpenJPA Users mailing list archive at Nabble.com.