Hi,
I'm having problems while making rollback of a transaction after persist a new entity and executing a query on it.
Code:
TesteEJB teste=new TesteEJB();
teste.setCancelable(false);
teste.setFirst(true);
teste.setHelp("OK");
em.persist(teste);
System.out.println(teste);
TesteEJB find = em.find(TesteEJB.class, teste.getId());
System.out.println(find);
List<TesteEJB> list=em.createQuery("from TesteEJB t where t.id=?")
.setParameter(1, teste.getId())
.getResultList();
for(int i=0;i<list.size();i++) {
System.out.println(list.get(i));
}
context.setRollbackOnly();
The entity manager and context are being injected.
Code:
@PersistenceContext(unitName = "gwf")
public EntityManager em; // injected by persistenceContext
@Resource
private SessionContext context;// injected by persistenceContext
After running this code, the entity is available in the database.
I’m running this code on JBoss 4.2.2 with an Oracle 9i database.