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 The following application-managed but EntityManager always has to be in the transaction if it is used for continuous use?
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);
find () orientation works fine.