richard-grin opened a new issue, #4839:
URL: https://github.com/apache/netbeans/issues/4839

   ### Apache NetBeans version
   
   Apache NetBeans 16 release candidate
   
   ### What happened
   
   In an EJB, Alt+Insert > Use Entity Manager... generate these lines:
   `    @PersistenceContext(unitName = "xxxxx")
       private EntityManager em;
       @javax.annotation.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);
           }
       }`
   The bad namespace javax is used if the project is a Jakarta EE 9.1 project. 
Overall, it is not the good code when the transactions are managed by the EJB 
(value by default for an EJB; it would be the good code if the EJB were 
annotated with `@TransactionManagement(TransactionManagemenType.BEAN)`)
   The good code:
   ```
   @PersistenceContext(unitName = "xxxxx")
     private EntityManager em;
   
     public void persist(Object object) {
       em.persist(object);
     }
   ```
   
   
   ### How to reproduce
   
   Create a Maven Web application project.
   Write a persistence.xml file.
   Create an EJB.
   In an EJB, Alt+Insert > Use Entity Manager..
   
   ### Did this work correctly in an earlier version?
   
   Apache NetBeans 12.6 or earlier
   
   ### Operating System
   
   Windows 11 Family 64-bit, version 21H2
   
   ### JDK
   
   11
   
   ### Apache NetBeans packaging
   
   Apache NetBeans provided installer
   
   ### Anything else
   
   I don't remember in which earlier version the good code was generated.
   
   ### Are you willing to submit a pull request?
   
   No
   
   ### Code of Conduct
   
   Yes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to