netbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Grin (JIRA)" <>
Subject [jira] [Created] (NETBEANS-2934) Code generated to inject an EntityManager is not adapted to CMT mode
Date Thu, 01 Aug 2019 15:16:00 GMT
Richard Grin created NETBEANS-2934:

             Summary:  Code generated to inject an EntityManager is not adapted to CMT mode
                 Key: NETBEANS-2934
             Project: NetBeans
          Issue Type: Bug
    Affects Versions: 11.1
         Environment: Windows 10, NetBeans 11.1
            Reporter: Richard Grin

Alt-Insert to inject an EntityManager in an EJB is not good when the EJB is CMT.

The code generated by NetBeans for the injection of an EntityManager is 
 not adapted to the CMT (Container Managed Transaction) mode. "Generate" 
 menu for "Insert code..." > "Use Entity Manager...".

The generated code: 
    @PersistenceContext(unitName = "xxx")
     private EntityManager em;
     private javax.transaction.UserTransaction utx;

    public void persist(Object object) {
         } catch (Exception e) {
 Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception 
 caught", e);
             throw new RuntimeException(e);
It should be

@PersistenceContext(unitName = xxx")
 private EntityManager em;
public void persist(Object object) { em.persist(object); }
The generated code was good in NetBeans 9; I did not try with NetBeans 10.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

For further information about the NetBeans mailing lists, visit:

View raw message