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.

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

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