-
1. Re: EntityManager cannot persist
jazir1979 Mar 7, 2008 2:58 AM (in response to yuriy_zubarev)The entity manager won't send anything to the DB until em.flush() is called, and none of it will be committed until the underlying transaction committed.
What kind of environment are you running Seam in, and what's your transaction provider?
-
2. Re: EntityManager cannot persist
yuriy_zubarev Mar 7, 2008 3:30 AM (in response to yuriy_zubarev)Of course! Thank you.
I'm running under Tomcat 6. Transaction-type is RESOURCE_LOCAL
and provider is org.hibernate.ejb.HibernatePersistence. Everything is fine now:EntityTransaction t = this.entityManager.getTransaction(); t.begin(); this.entityManager.persist(client); t.commit();
By the way, is there more concise way of doing it?
-
3. Re: EntityManager cannot persist
jazir1979 Mar 7, 2008 3:52 AM (in response to yuriy_zubarev)Take a look at the section on seam managed transactions, I think this is probably what you need. http://docs.jboss.com/seam/2.0.0.GA/reference/en/html_single/#persistence.seam-managed-transactions
-
4. Re: EntityManager cannot persist
rollinm Aug 31, 2008 4:36 AM (in response to yuriy_zubarev)I have been working with seam 2.0.2sp1 running in jboss4.0.2.
I have a similar issue that was described here. I have an action that I want to trigger as an asynchronous method. The async method needs to update the database.
I've tried using the hibernate session and the entitymanager to update the db, but in both cases, the updates or inserts are never commited to the db. If I change it to synchronous call everything works fine.
db update bean
@Name("updateScan") public class UpdateScan { @In private EntityManager entityManager; private boolean isRunning; @Observer("items.changed") public void sessTest() { Session s = (Session) entityManager.getDelegate(); Mediavideoext mve = new Mediavideoext(); mve.setLanguage("hi"); Transaction tr = s.beginTransaction(); s.save(mve); tr.commit(); } }
Call from page bean:
//this does not work Events.instance().raiseAsynchronousEvent("items.changed"); //this will work Events.instance().raiseEvent("items.changed");
If there's some examples or pointers using asynchronous and db updates to a db from within a Seam app I would appreciate the references.
Thanks
-
5. Re: EntityManager cannot persist
rollinm Aug 31, 2008 8:45 PM (in response to yuriy_zubarev)Correction running jboss 4.2.2GA