You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Richard Grin <Ri...@univ-cotedazur.fr> on 2020/09/25 09:43:39 UTC

Alt-insert "Use an Entity Manager" does not work

Hello,

In a Maven Web application, NetBeans 12.1, Windows 10.

Alt-Insert "Use an Entity Manager..." in an EJB stateless inserts code 
for a bean managed transaction, even if the transaction is managed by 
the container.

Code inserted:

   @PersistenceContext(unitName = "customerPU")
   private EntityManager em;
   @Resource
   private javax.transaction.UserTransaction utx;

   public void persist(Object object) {
     try {
       utx.begin();
       em.persist(object);
       utx.commit();
     } catch (Exception e) {
       Logger.getLogger(getClass().getName()).log(Level.SEVERE, 
"exception caught", e);
       throw new RuntimeException(e);
     }
   }

Code that should have been inserted:

@PersistenceContext(unitName = "customerPU")
   private EntityManager em;

public void persist(Object object) {
   em.persist(object);
}

This is a regression. It worked in older versions of NetBeans but I 
can't remember which ones.

Richard


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists