Hi Everyone, I started working on https://issues.apache.org/jira/browse/NETBEANS-3270 ticket which seems related to it.
Thanks and kind regards, Gaurav Gupta On Wed, Oct 6, 2021 at 4:04 PM Richard Grin <richard.g...@univ-cotedazur.fr> wrote: > Hello, > > It's a regression but I don't remember in which version it worked (some > years ago). It does not work in 12.4 nor in 12.5 (Windows 10). > > The option "Insert code..." > "Use Entity Manager..." of the context > menu of a session bean stateless does not insert the good code. > > Even if the transactions are not managed by the EJB (the behaviour by > default), it inserts this code (this code would be good if the > transaction was managed by the EJB, i.e. in an EJB annotated by > "@TransactionManagement(TransactionManagementType.BEAN)"): > > @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); > } > } > > It should insert this code: > > @PersistenceContext(unitName = "customerPU") > private EntityManager em; > > public void persist(Object object) { > em.persist(object); > } > > Example of the code of the EJB in which I try to insert the code : > > @Stateless > public class Test { > > } > > Richard > >