users@glassfish.java.net

Re: Logic in entity beans - a design question

From: <glassfish_at_javadesktop.org>
Date: Wed, 17 Dec 2008 09:17:51 PST

Are we talking about update logic in terms of calling the EntityManager, or simply pushing values around in the object model represented by the Entity Beans?

If we're just talking about model updates, then that logic could certainly live within the EntityBeans.

If we're talking about EM calls, then it gets more wiggly, because I personally like to try and ensure there's no dependency in my Entity Beans to the actual persistence plumbing.

One way you can do that, however, is that you can leave the logic in the Entity Beans, but pass in the Entity Manager and any other server artifacts. That keeps the Entity Bean more disconnected than, say, a Session Bean.

I don't think that's particularly horrible.

For me, I like to move my Entity Beans back and forth having them work as a fusion (perhaps even confusion) of Entity Beans, Data Model, and DTOs from the EJB tier to the web tiers, etc.

But I wouldn't have a real problem adding bean specific code that relies on the Entity Manager as long as the EM is passed in and these calls aren't necessary to be made on the client side.
[Message sent by forum member 'whartung' (whartung)]

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