There's more...

Another important piece of code is the following:

@Stateful
public class UserBean {

@PersistenceContext(unitName = "ch02-jta-pu",
type = PersistenceContextType.EXTENDED)
private EntityManager em;

...
}

So, here we are defining our PersistenceContext as EXTENDED. It 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 would live only by the time of transaction.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.173.238