Hi,

I've created a OneToMany bidirectional relationship between two tables.  The 
problem I'm having is a Hibernate exception when I go to delete the child 
object.  According to the EJB3 book recently published by O'reilly it says to 
ensure the operation is performed from the ManyToOne side or the database 
operations won't happen.  It's when I do this that I get the exception 
(optional = false on the ManyToOne so I have to use the EM and just do a 
remove).


  | parent.getKids().remove(kid);
  | em.remove(kid);  // Throws exception
  | 

throws


  | Caused by: javax.persistence.PersistenceException: 
org.hibernate.NonUniqueObjectException: a different object 
  | with the same identifier value was already associated with the session: 
[com.ati.raa.entities.TdmUserMapping#4
  | 52]
  |         at 
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.jav
  | a:567)
  |         at 
org.hibernate.ejb.AbstractEntityManagerImpl.remove(AbstractEntityManagerImpl.java:225)
  |         at 
org.jboss.ejb3.entity.TransactionScopedEntityManager.remove(TransactionScopedEntityManager.java:187
  | )
  |         at 
com.ati.raa.bl.UserLogicBean.removeUserMapping(UserLogicBean.java:98)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |         at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |         at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |         at java.lang.reflect.Method.invoke(Method.java:585)
  |         at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
  |         at 
org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
  |         at 
org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
  |         at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |         at 
org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManag
  | erInterceptor.java:54)
  |         at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |         at 
org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
  |         at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |         at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
  |         ... 49 more
  | 

If it's relevant I'm using JBoss 4.0.4.GA on Java 1.5.0_06 (OS X) talking to 
PostgreSQL 8.1, and of course the EJB3 deployment profile for JBoss.

I'm sure this is something I'm not sure about with the session, but I've been 
really beating myself up over this for about a week now and I need to resolve 
the issue.  Any help would be much appreciated.

Thanks,
Mike

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3953719#3953719

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3953719

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to