users@glassfish.java.net

Ejb3 Entity graph serialization problem?

From: <glassfish_at_javadesktop.org>
Date: Fri, 05 Sep 2008 03:16:54 PDT

These happen on both SJSAS 9.1_02 and Glassfish v2ur2 with the default JPA provider (toplink and toplink essentials I believe):

I have two ejb3 entities, EntityA having a unidirectional ManyToOne relationship to EntityB. My DAO ejb3 slsb loads a list of EntityA-s with a select, and logs out all EntityA.getEntityB().getSomeProperty() which has the correct not-null value. After the log message, I return the List<EntityA> to the caller.

From an other EAR I do a remote EJB call to the DAO mentioned and log the results. All EntityA.getEntityB().getSomeProperty() calls return null now. EntityA.getEntityB() has the class type of EntityB (does not appear to be a proxy), but all properties inside EntityB are null which were correctly set in the DAO as logged right before returning the results.

Trying to narrow down the problem, I replaced the entityManager call loading the list of results with plain object creation (new ArrayList() etc) to get rid of any possible Toplink magic. The problem still exists, appearently serializing a List<EntityA> fails silently with EntityA.getEntityB() being all null inside. Replacing EntityA and EntityB with plain POJOs (not entity beans anymore) make the problem disappear.

What's going on here?

Thanks,
Kristof
[Message sent by forum member 'kjozsa' (kjozsa)]

http://forums.java.net/jive/thread.jspa?messageID=297408