-
1. Re: Using EJB3 in jsps - please help
epbernard May 2, 2005 6:35 AM (in response to binario)Absolutly, you can use EJB3 entities in your jsps/action classes.
What you be aware of is to fetch all your needed proeprties/associations before sending the entity back to the upper layers.
detach/attach is used to update some objects (entities) in your upper layer (presentation) and synchronize them to your DB through a merge in your entity manager. -
2. Re: Using EJB3 in jsps - please help
kabirkhan May 2, 2005 6:37 AM (in response to binario)Yes, you can use the entity beans as dto's.
Once passed out of the EJB container to the web container the entities are no longer attached to the database. This means that you for example cannot lazy load relationships from the web layer, but need to make sure your session bean layer eager loads any data that will be needed. If you change the data of an entity in the web layer, you can pass it back to the session layer and update the data in the database using EntityManager.merge() -
3. Re: Using EJB3 in jsps - please help
binario May 2, 2005 7:06 AM (in response to binario)Thanks guys!
This is excellent! You've just saved me LOADS of coding! Really appreciate it! Just to confirm one thing - the attachment/reattachment is handled seamlessly as far as I am concerned correct?
Once the entity manager passes the ejb3 object back to me from a session bean, it's detached, and until I call a session bean method something like
public void update(Object myDetachedObject){
entityManager.merge(myDetachedObject);
}
it doesn't get reattached, right?
thanks a million,
Brian -
4. Re: Using EJB3 in jsps - please help
kabirkhan May 2, 2005 7:11 AM (in response to binario)Correct :-)