
上QQ阅读APP看书,第一时间看更新
There's more...
Another important piece of code is the following one:
@Stateful
public class UserBean {
@PersistenceContext(unitName = "ch02-jta-pu",
type = PersistenceContextType.EXTENDED)
private EntityManager em;
...
}
Here, we are defining PersistenceContext as EXTENDED. This means that this persistence context is bound to the @Stateful bean until it is removed from the container.
The other option is TRANSACTION, which means the persistence context will only live for the duration of the transaction.