java ee - Can EntityManager be used only within transaction? -
It's obvious that as far as not mentioned, but I still feel the need to confirm it . code EntityManager always has to be in the transaction if it is used for continuous use?
The following application-managed
EntityManager does not enter the code until I attach it to the
getTransaction (). and
getTransaction (). Commit () :
EntityManager em = entityManagerFactory .createEntityManager (); Event E = New Event ("One Name", New Date ()); em.persist (e); but find () orientation works fine.
- Does this mean that I can not use EM for writing / updating operations unless that is within the transaction? If that's the case why no exception was thrown when I tried to use it without the transaction? If EM is not within the transaction, can EM be set up to automatically start and transaction?
- In the case of Container Managed EM, in the context of the same EM example, the various components injected within a transaction are part of 1 transaction in transactions or in many EM examples?
- Can 1Em example be used in many transactions?