[EJB 3.0] - Re: deleted entity passed to persist exception ???
by nonreva
With Jboss 4.2.2GA I am experiencing a similar problem.
The gist of it is (within a single container managed transaction):
1. I remove an item from this collection...
| @OneToMany(mappedBy = "ivrAccount", cascade = CascadeType.ALL)
| public Collection<LinkedAccountBean> linkedAccounts = new HashSet<LinkedAccountBean>();
2. I perform a query on another bean...
| try {
| System.out.println("************ 1 **************");
| String number = accountReference.getNumber();
| System.out.println("************ 2 ************** " + number);
|
| Query q= em.createNamedQuery(
| BankAccountReference.FIND_BY_ACCOUNT_NUMBER_QUERY)
| .setParameter("number", number);
| System.out.println("************ 3a **************");
| Object o = q.getSingleResult();
| System.out.println("************ 3b **************");
| linkedAccount.accountReference = (BankAccountReference) o;
| System.out.println("************ 3c **************");
|
| } catch (NoResultException ex) {
| System.out.println("************ 4 **************");
| linkedAccount.accountReference = BankAccountReferenceHelper
| .createBankAccountReference(em, accountReference);
| } catch (EntityNotFoundException ex) {
| System.out.println("************ XXXXX **************");
| throw ex;
| }
|
This results in an EntityNotFoundException...
| 14:29:51,593 ERROR [STDERR] Caused by: javax.persistence.EntityNotFoundException: deleted entity passed to persist: [ae.
| hilal.j2ee.entity.account.LinkedAccountBean#<null>]
| 14:29:51,593 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityM
| anagerImpl.java:613)
| 14:29:51,593 ERROR [STDERR] at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:99)
| 14:29:51,593 ERROR [STDERR] at ae.hilal.j2ee.session.helper.LinkedAccountHelper.update(LinkedAccountHelper.java:40)
| 14:29:51,593 ERROR [STDERR] at ae.hilal.j2ee.session.helper.LinkedAccountHelper.createLinkedAccount(LinkedAccountHel
| per.java:123)
|
This can be seenn from the following output:
16:40:02,156 INFO [STDOUT] ************ 1 **************
| 16:40:02,156 INFO [STDOUT] ************ 2 ************** 4444444444
| 16:40:02,156 INFO [STDOUT] ************ 3a **************
| 16:40:02,156 INFO [STDOUT] ************ XXXXX **************
this appears to me to be the cause of a
anonymous wrote : 14:29:51,593 ERROR [STDERR] javax.ejb.EJBTransactionRolledbackException: deleted entity passed to persist: [ae.hilal.j2e
| e.entity.account.LinkedAccountBean#]
| 14:29:51,593 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
| ...
What is ironic about this is that if I do the remove after the query it works... i.e. I collect up the objects that need to be removed and I remove them after I have done additions and updates to the collection.
Whilst this workaround appears to solve the problem in this particular instance, there is only an indirect relationship between the object deleted and the query. Furthuermore I am not convinced that if further queries were to follow the delete (untested scenarios) that these might also lead to problemd.
The EJB persistence specification (A.4) says that
anonymous wrote : Replaced EntityNotFoundException with NoResultException in
| entities might be returned, and exception should be recoverable., so I am also wondering why such an exception is still being propagated from a query (if my understanding of the stack trace is correct)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4171657#4171657
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4171657
17 years, 8 months
[JBoss jBPM] - Re: workaround for StackOverflow exception
by alex.guizar@jboss.com
JBSEAM-1575 depends on JBPM-1135 which is already resolved. That said, I have two suggestions.
The first is to replace the timer with an asynchronous continuation, unless you need the delay (which I understand you do not). Just set the node's async attribute to true. It does not need to be a separate emtpy state, you can decorate any of your existing nodes with that attribute.
The second is to implement a ThreadLocal based solution which prevents recursive calls once the loop node is reached. I came to it for preventing the stack overflow in the BPEL while activity, but it can be implemented for jPDL as well. You can browse the code in the online repository. Look at Loop.execute(). It is much of a hack - you might want to stick to asynchronous continuations unless you need more performance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4171652#4171652
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4171652
17 years, 8 months