20 abril 2009

persist an entity (Serializable) on application-managed entity manager

from Standardizing Java Persistence with the EJB3 Java Persistence API

If you persist an entity, any state changes to associated entities will be persisted as well if CascadeType for the relationship is set to PERSIST or ALL. Unless you're using an extended persistent context, the entities will become detached after the end of the transaction. The merge operation lets you merge a detached entity instance with the persistent context; the state of a detached entity will be synchronized with the database. This helps you get rid of the Data Transfer Object (DTO) anti-pattern prevalent in EJB 2.x because entities, being POJOs, can be transferred between tiers. The only requirement is that the entity class must implement the java.io.Serializable interface.

No hay comentarios: