I have 2 tables and one of them has a foreign key on the other table. I insert the data in to the first table which gets inserted properly. When I try to insert data in the child table which has a foreign key on the first table, I get an error saying parent key not found... here is the dump. I Cannot understand as to why this happen when the data which is a foreign key is already inserted...
Caused by: com.nasd.fms.framework.database.DaoException: Exception in HibernateDao.insert()! at com.nasd.fms.framework.database.HibernateDao.insert(HibernateDao.java:250) at com.nasd.fms.framework.database.HibernateDao.insert(HibernateDao.java:220) at com.nasd.mrdt.MRDTMappingDriver.prepareDataForSavings(MRDTMappingDriver.java:90) at com.nasd.fms.xread.MappingManagerImpl.Transform(MappingManagerImpl.java:145) ... 20 more Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301) at $Proxy0.flush(Unknown Source) at com.nasd.fms.framework.database.HibernateDao.insert(HibernateDao.java:239) ... 23 more Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (NMAOWNER.SYS_C002743) violated - parent key not found
at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:458) at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4105) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
Paras Jain
Ranch Hand
Joined: Feb 26, 2005
Posts: 137
posted
0
Looks like there is some problem in the hibernate mapping file. Please post the contents of the hbm mapping files for parent and child object