I don't see any issues. Is it possible that you have a TestEntity in your DB that doesn't have any children (bad data) in your DB from a previous run?
Also, why are you calling em.merge(..)? That call is unnecessary as the results from your query already are a part of your persistence context. Thanks, Rick On Thu, Aug 4, 2011 at 7:51 AM, Michael Pflueger <michael.pflue...@sma.de>wrote: > Hi, > > I'm digging through some of my OpenJPA problems and came across this issue. > I get a NPE when I access te2.getChildren().xyz(), but only when I merge > the object before the access AND the lazy association is not yet fetched AND > I set Cascadetype.MERGE on the association. > > List<TestEntity> entities = query.getResultList(); > for (TestEntity te : entities) { > TestEntity te2 = em.merge(te); > System.out.println(te2.getChildren().size()); > } > > I'm using OpenJPA 2.1.0 with the MySQL connector. > Attached is the full source and persistence.xml. > > Can anybody reproduce this and is this a bug? > > Regards, > Michael > ___________________________________________________ > > SMA Solar Technology AG > Aufsichtsrat: Guenther Cramer (Vorsitzender) > Vorstand: Juergen Dolle, Roland Grebe, Uwe Hertel, Pierre-Pascal Urbon, > Marko Werner > Handelsregister: Amtsgericht Kassel HRB 3972 > Sitz der Gesellschaft: 34266 Niestetal > USt-ID-Nr. DE 113 08 59 54 > WEEE-Reg.-Nr. DE 95881150 > ___________________________________________________ > -- *Rick Curtis*