Yes, please do.
https://issues.apache.org/jira/projects/NETBEANS/issues/NETBEANS-2931?filter=allopenissues

On Thu, Aug 1, 2019, 9:29 AM Richard Grin <richard.g...@univ-cotedazur.fr>
wrote:

> Do I have to report this problem elsewhere for it to have a chance to be
> fixed?
>
> I found other problems in other codes generated by NetBeans and I prefer
> to report them the right way.
>
> Regards,
>
> Richard
> Le 29/07/2019 à 16:06, Richard Grin a écrit :
>
> Hi Ortiz,
>
> The EJB in which I inject is NOT annotated by
>
> @TransactionManagement( TransactionManagementType.BEAN)
>
> so, by default, the transactions are managed by the container: one
> automatic commit or rollback at the end of the method which started the
> transaction (I won't go into the details... ; see
> https://javaee.github.io/tutorial/transactions004.html#BNCIJ). A
> UserTransaction must not be used. The old versions of NetBeans inserted the
> good code.
>
> See the code of Arjan Tijms in
> https://stackoverflow.com/questions/8772175/how-to-implement-container-managed-transaction-cmt
> .
>
> Regards,
>
> Richard
> Le 29/07/2019 à 13:33, Javier Ortiz a écrit :
>
> The current one seems completely correct to me. What error/problem are you
> getting?
>
> That's an atomic operation.
>
> On Mon, Jul 29, 2019, 5:31 AM Richard Grin <richard.g...@univ-cotedazur.fr>
> wrote:
>
>> Hi,
>>
>> NetBeans 11.1.
>>
>> 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;
>>      @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 be
>>
>>      @PersistenceContext(unitName = xxx")
>>      private EntityManager em;
>>
>>      public void persist(Object object) {
>>          em.persist(object);
>>      }
>>
>> Richard
>>
>> --
> Cordialement,
>
> Richard Grin
>
> --
> Cordialement,
>
> Richard Grin
>
>

Reply via email to