Overview
Other MyFaces Extensions
- ExtVal
- Ext-Script
- [Orchestra]
- [Portlet Bridge]
Community
Development
Sponsorship
Your browser does not support iframes
...
The @Transactional annotation of Apache MyFaces CODI will maintain an own transcaction context which automatically starts when an @Transactional method gets invoked, and ends when the outermost @Transactional method returns. This might for example be used to create @TransactionScoped EntityManagers. The effect of such an EntityManager is similar to using EJBs: when the outermost @Transactional method returns, the @TransactionScoped EntityManager will get destroyed and thus em.close() will get called effectively detaching all entities.
This scope is esp. useful if the loaded entities have to be cached.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public class DataBaseProducer { @PersistenceContext(unitName="default") private EntityManager entityManager; @Produces @TransactionScoped public EntityManager createEntityManager() { return this.entityManager; } public void dispose(@Disposes EntityManager entityManager) { if(entityManager.isOpen()) { entityManager.close(); } } } |
...