Remote EJB with EclipseLink and Glassfish does not work when you try to return an object.
Same for Hibernate, you need to delete the whole proxy server before returning the response. With Hibernate, you need to clear and clear the persistence context before deleting the proxy. If not loaded, set the attribute to null. You can make it work with Java EE interceptor.
But EclipseLink does not work like Hibernate. Even if you clear the persistence context, get / set on the lazy attribute will try to extract. Even out of the deal.
If you set the property name = "eclipselink.weaving" value = "false", this will work because EclipseLink will not change the bytecode of your POJO class, but ManyToOne will always be extracted. In this way, it can load the database into memory.
The only way to resolve this is to use DTO or use Hibernate with an interceptor.
EDIT: You can always override serialization of an entity using the Externalization interface. Get the object in the field to make sure that lazy selection is not applied.
Openjpa also apparently uses the weaving method. http://openjpa.apache.org/entity-enhancement.html
source share