users@glassfish.java.net

Re: EntityManager, EntityManagerFactory and UserTransaction

From: <glassfish_at_javadesktop.org>
Date: Mon, 27 Jul 2009 11:30:39 PDT

Thanks so much Marina.

I would like to give you my email address: vlad.balan_at_gmail.com and if i don't disturb you, pls send me an email to have yours. There are cases in which i need an expert opinion pretty urgent.

I won't be bothering you more than i did on the forum. If it is not possible, never mind :)

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?
[Message sent by forum member 'vladbalan' (vladbalan)]

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