Well as far as I recall, XToMany relationships are lazy by default as per the spec. That means the object must be managed (attached, in the same transaction, using an EPC) if you want to access the relationship content. Otherwise, either openjpa and hibernate throws an exception which is in my opinion fine.
I've heard Eclipselink sometimes does not behave always the same. So basically, yes calling size when the object is still attached fires the load of the toMany relationship but that becomes the same than changing LAZY to EAGER in the mapping. Another way depending on the architecture (DAO, or not, etc ...) is to use a flag when you need to access the content of the ToMany relationship. You can use JOIN FETCH queries as well so that you can populate with the same query and then avoid another SQL stmt to the RDBMS. Finally, we are working on a brand new distribution PLUME (stands for TomEE PLus Mojorra Eclipselink). As we support already out of the box Glassfish descriptor, the aim of this distribution is to switch from MyFaces to Mojorra for JSF and from OpenJPA to Eclipselink for JPA. We hope that can help projects to migrate more easily. Unfortunately, PLUME is not well certified and we need to fix some remaining issues. In anyway, I would suggest to fix the application if you can of course, cause LAZY means you can access if the entity is still managed. When the unit of work is finished (ie. Extended PC closed or transaction committed) the entity is no more managed --> LazyLoadingException Of course, this is not directly TomEE related, but JPA is fully part of the web profile and what we provide out of the box in TomEE. So you are welcome ;-) Hope that helps Jean-Louis -- Jean-Louis Monteiro http://twitter.com/jlouismonteiro http://www.tomitribe.com On Fri, Jun 27, 2014 at 4:42 PM, pablo.a.saave...@gmail.com < pablo.a.saave...@gmail.com> wrote: > Hi, > > I had the same problem going from glassfish to tomee (eclipselink -> > openjpa), collections are lazily fetched and you can't access them outside > of the transaction. My solution was to log the size of the collection > inside the session bean method... ugly but it worked. > > Regards > > > On 27 June 2014 11:25, hwaastad <he...@waastad.org> wrote: > > > Hi, > > I've startet to see if I can migrate some of my projects from using > > eclipselink 2.5.1 to openjpa 2.4xx. > > > > Does anyone know if there are any resources anywhere which discribes > this?. > > > > I've just switched provider to openjpa and it seems that openjpa fetches > > differently from eclipselink. > > > > example: > > > > 1. use deltaspike repository with jta support > > > > 2. Stateless ejb handling request from cdi beans (View access scope) > > > > 3. onetomany are lazy fetched and unidirectional > > > > in my @VASB i fecth all customers via ejb call > > if I try getchildcollection for one of my parents in @VASB, it returns > > null. > > > > Switching back to eclipselink, get child collection returns collection. > > (and > > i off cource see the sql logs) > > > > I'm quite new to openjpa, but I would expect the two would operate > similar > > without any changes...but obviously not. > > > > This is tomee 1.7.0-snapshot. > > > > My idea was actually to get openjpa works the same way my eclipselink > > implementation was, and the add LRS features and more. > > > > If this is not tomee dependent, I'll move over to stackoverflow :-) > > > > br hw > > > > > > > > > > > > -- > > View this message in context: > > > http://tomee-openejb.979440.n4.nabble.com/tomee-eclipselink-openjpa-tp4670212.html > > Sent from the TomEE Users mailing list archive at Nabble.com. > > >