richard-grin opened a new issue #3874:
URL: https://github.com/apache/netbeans/issues/3874
### Apache NetBeans version
Apache NetBeans 13
### What happened
It is a regression of an older version (I don't remember the last version)
that worked: the code inserted was not the same whether the transaction is
managed by the container or by the bean.
In an EJB session, Insert Code > Unse Entity Manager..." does not insert the
good code when the transaction is managed by the container (the more frequent
case).
The code inserted for the method persist is
`
@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);
}
}`
whereas it should be
`public void persist(Object object) {
em.persist(object);
}`
### How to reproduce
In a new project Java with Maven > Web Application, add the provider and the
jta-data-source in persistence.xml.
Then create a new Session Bean:
New > Session Bean
Check Stateless
In the body of the EJB, Insert Code > Use Entity Manager..., the bad code is
inserted.
### Did this work correctly in an earlier version?
Apache NetBeans 12.3 or earlier
### Operating System
Windows 11
### JDK
11
### Apache NetBeans packaging
Apache NetBeans provided installer
### Anything else
_No response_
### 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