-
1. Re: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
wdfink Aug 25, 2012 12:39 PM (in response to rino.covelli)I suppose the problem is that your EJB transaction is managed by the container (CMT).
If you want to control the transaction you should set the TransactionManagement to BEAN
-
2. Re: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
rino.covelli Aug 28, 2012 6:51 AM (in response to wdfink)I did not understand. you give me an example?
-
3. Re: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
wdfink Aug 28, 2012 8:05 AM (in response to rino.covelli)In your Bean you have only the annotation @Stateless in this case the transaction is container managed (CMT).
If you want to control the Tx demarcation you should add @TransactionManagement(TransactionManagementType.BEAN)
If you want only a Tx for your method I recommend to use CMT and add @TransactionAttribute(TransactionAttributeType.REQUIRED) in that case the container will do all the work.
Your method can be look like:
@Override
public void savePrivato(String nome , String cognome) {
Privato pr = new Privato();
pr.setNome(nome);pr.setCognome(cognome);
em.persist(pr);
System.out.println("Utente Salvato");
}