-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Deleting many-to-many element causes an exception
PostPosted: Mon Aug 29, 2005 9:08 am 
Newbie

Joined: Mon Aug 29, 2005 8:34 am
Posts: 1
Hi,

I am using Hibernate version 2.1.8 and Oracle DB version 9.2.04.

This is the definition of the elements used in the many-to-many relations:
<bag
name="values"
table="TABLE_VALUE"
lazy="true"
cascade="all-delete-orphan">
<cache usage="read-write"/>
<key column="TABLE_ID"/>
<many-to-many
class="ValueImpl"
column="VALUE_ID"/>
</bag>

<bag
name="tables"
table="TABLE_VALUE"
inverse="true"
lazy="true">
<cache usage="read-write"/>
<key column="VALUE_ID"/>
<many-to-many
class="TableImpl"
column="TABLE_ID"/>
</bag>

At run time I have one 'value' element associated to elements 'table1' and 'table2'.
When I try to delete a table element using:
session.delete(table1)

I get the following exception:
15:24:19,896 WARN [JDBCExceptionReporter] SQL Error: 2292, SQLState: 23000
15:24:19,896 ERROR [JDBCExceptionReporter] ORA-02292: integrity constraint (EDOV
ER.FKC43C6A54C0305DF9) violated - child record found

15:24:19,896 WARN [JDBCExceptionReporter] SQL Error: 2292, SQLState: 23000
15:24:19,896 ERROR [JDBCExceptionReporter] ORA-02292: integrity constraint (EDOV
ER.FKC43C6A54C0305DF9) violated - child record found

15:24:19,916 WARN [JDBCExceptionReporter] SQL Error: 2292, SQLState: 23000
15:24:19,916 ERROR [JDBCExceptionReporter] ORA-02292: integrity constraint (EDOV
ER.FKC43C6A54C0305DF9) violated - child record found

15:24:19,916 WARN [JDBCExceptionReporter] SQL Error: 2292, SQLState: 23000
15:24:19,916 ERROR [JDBCExceptionReporter] ORA-02292: integrity constraint (EDOV
ER.FKC43C6A54C0305DF9) violated - child record found

15:24:19,916 ERROR [SessionImpl] Could not synchronize database state with sessi
on
15:24:19,976 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from c
lass path resource [org/springframework/jdbc/support/sql-error-codes.xml]
15:24:19,997 INFO [DefaultListableBeanFactory] Creating shared instance of sing
leton bean 'DB2'
15:24:20,017 INFO [DefaultListableBeanFactory] Creating shared instance of sing
leton bean 'HSQL'
15:24:20,017 INFO [DefaultListableBeanFactory] Creating shared instance of sing
leton bean 'MS-SQL'
15:24:20,017 INFO [DefaultListableBeanFactory] Creating shared instance of sing
leton bean 'MySQL'
15:24:20,017 INFO [DefaultListableBeanFactory] Creating shared instance of sing
leton bean 'Oracle'
15:24:20,017 INFO [DefaultListableBeanFactory] Creating shared instance of sing
leton bean 'Informix'
15:24:20,017 INFO [DefaultListableBeanFactory] Creating shared instance of sing
leton bean 'PostgreSQL'
15:24:20,017 INFO [DefaultListableBeanFactory] Creating shared instance of sing
leton bean 'Sybase'
15:24:20,017 INFO [SQLErrorCodesFactory] SQLErrorCodes loaded: [DB2, HSQL, MS-S
QL, MySQL, Oracle, Informix, PostgreSQL, Sybase]
15:24:20,067 ERROR [LogInterceptor] RuntimeException in method: public abstract
void com.bmc.idm.cmplmgr.command.common.policyadmin.PolicyAdminCommand.deletePol
icy(com.bmc.common.authentication.IIdentityContext,java.lang.String) throws com.
bmc.idm.cmplmgr.exception.common.BackendException,java.rmi.RemoteException
org.springframework.dao.DataIntegrityViolationException: (HibernateTransactionMa
nager): data integrity violated by SQL ''; nested exception is java.sql.BatchUpd
ateException: ORA-02292: integrity constraint (EDOVER.FKC43C6A54C0305DF9) violat
ed - child record found

java.sql.BatchUpdateException: ORA-02292: integrity constraint (EDOVER.FKC43C6A5
4C0305DF9) violated - child record found

at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:4
59)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePrepare
dStatement.java:4210)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingSt
atement.java:294)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.
java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:128)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:6
1)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:5
8)
at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.j
ava:111)
at net.sf.hibernate.persister.EntityPersister.delete(EntityPersister.jav
a:564)
at net.sf.hibernate.impl.ScheduledDeletion.execute(ScheduledDeletion.jav
a:29)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2397)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:61)
at org.springframework.orm.hibernate.HibernateTransactionManager.doCommi
t(HibernateTransactionManager.java:490)
at org.springframework.transaction.support.AbstractPlatformTransactionMa
nager.commit(AbstractPlatformTransactionManager.java:401)
at com.bmc.idm.cmplmgr.transaction.backend.AbstractSpringTransactionAspe
ct.enterTransactedMethod(AbstractSpringTransactionAspect.java:77)
at com.bmc.idm.cmplmgr.command.backend.policyadmin.PolicyAdminCommandImp
l_1__1351917967_1711586941___AW_JoinPoint.proceed(Unknown Source)
at com.bmc.idm.cmplmgr.command.backend.policyadmin.PolicyAdminCommandImp
l_1__1351917967_1711586941___AW_JoinPoint.invoke(Unknown Source)
at com.bmc.idm.cmplmgr.command.backend.policyadmin.PolicyAdminCommandImp
l.deletePolicy(PolicyAdminCommandImpl.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(S
tatelessSessionContainer.java:683)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invo
ke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
rceptor.java:84)
at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxI
nterceptorBMT.java:144)
at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:6
2)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(Stat
elessSessionInstanceInterceptor.java:72)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.
java:111)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFacto
ryFinderInterceptor.java:122)
at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessi
onContainer.java:331)
at org.jboss.ejb.Container.invoke(Container.java:709)
at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:197)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
360)
at sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:534)


The constraint points to table 'TABLE_VALUE'.
Using debug, it seems that when deleting element 'table1' it tries to delete element 'value' even tough it is still connected to 'table2' and fails.

My question is what am I doing wrong to specify that the 'value' element should be deleted only in case it has no relations at all.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.