[jboss-user] [JBoss Seam] - Transaction recovery
breako
do-not-reply at jboss.com
Fri Jan 25 11:31:26 EST 2008
Hi,
I am using SEAM Managed EntityManager with FushMode set to Manual for a JTA datasource.
When I flush the EntityManager for some invalid update, I get a database exception.
I catch this exception, the entity I am updating is still attached and I try to correct the invalid data and then try to reflush the update. However I can't persist the change even though this time it is valid. I get a javax.persistence.TransactionRequiredException: no transaction is in progress exception.
I am wondering is there any way I can recover from transaction failure?
My code is below.
| @Name("manager")
| @Scope(CONVERSATION)
| public void SeamPOJO {
| @In
| private EntityManager em;
|
| @End
| public String commit () {
| // Create entity
| Person person = new Person();
| // set invalid data
| person.setName("namethatistoolong");
| em.persist(person);
| try {
| em.flush();
| } catch (Exception e) {
| // data is invalid correct it
| person.setName("john");
| em.flush();
| }
| }
|
~any advice, comments appreciated. Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123575#4123575
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123575
More information about the jboss-user
mailing list