users@glassfish.java.net

Style question about returning JPA entities from EJB

From: Ryan de Laplante <ryan_at_ijws.com>
Date: Fri, 09 Nov 2007 13:44:13 -0500

I'm not sure where else to ask a question like this.

Back in the EJB 2.x days with CMP, the CPM entities were not returned by
session beans. The entity would be converted into POJO value objects
before being returned. I used to put the value object POJOs in a common
jar file that the EJB project and EJB client project would depend on.

In the Java EE5 world, I have been returning the actual JPA entities
from my EJB3 session beans. Since the JPA entity classes live inside of
the EJB jar file, the persistence.xml lives in there too, and my web
project has a build dependency on the EJB project. This hasn't been a
big deal for me since I use EJB Local, but I've always wondered if this
is the right way to do it.

Can anyone share with me the Java EE5 patterns you use, or links to
pages that talk about this?


Thanks,
Ryan