Actually I did not reliazed about Transaction ;)
Hope helps in future
I am attempting something similar but can't seem to get a result. My query in the servlet works fine, but my update appears not to generate sql (based on hibernate show sql true) and I get no effect in the database. I have:
EntityManager em = (EntityManager) Component.getInstance("entityManager");
UserTransaction txn = Transaction.instance(); txn.begin(); enquiry.setStatus(status); em.persist(enquiry); txn.commit();
My servlet includes an @Name annotation, other than that its a standard servlet. There is no conversationId being passed to the servlet. Any help would be much appreciated.
Since there is no tx active when you call getInstance, your entity manager
knows nothing about your transaction. You need to call em.joinTransaction() after txn.begin().