users@glassfish.java.net

Re: EntityManager, EntityManagerFactory and UserTransaction

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Mon, 27 Jul 2009 15:01:33 -0700

glassfish_at_javadesktop.org wrote:
> Thanks so much Marina.
>
> In IBM Red Book "WebSphere Application Server Version 6.1 Feature Pack for EJB 3.0.pdf" page 75 there's a snippet like this:
>
>
> @Stateless
> @Remote
> public class EJB3BankBean implements EJB3BankService {
> @PersistenceUnit(unitName="ITSOBankEJB")
> private EntityManagerFactory entityManagerFactory;
> private EntityManager entityMgr;
> @PostConstruct
> public void init() {
> entityMgr = entityManagerFactory.createEntityManager();
> }
> ...
> public void addCustomer(Customer customer) throws ITSOBankException {
> System.out.println("addCustomer: " + customer.getSsn());
> entityMgr.joinTransaction();
> entityMgr.persist(customer);
> }
> ...
> @PreDestroy
> public void destroy() {
> if(entityMgr.isOpen()) entityMgr.close();
> }
> }
>
>
> I guess it is declared as a JTA persistence unit, right?

Right.

Regards,
-marina

> [Message sent by forum member 'vladbalan' (vladbalan)]
>
> http://forums.java.net/jive/thread.jspa?messageID=357750
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>