Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 269141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:47:22+00:00 2026-05-11T23:47:22+00:00

If I delete a record from the Parent table I want the corresponding records

  • 0

If I delete a record from the Parent table I want the corresponding records in the child table to be deleted. How can I make Hibernate delete from the Child table rather than attempt to update with a null?

I’m using Hibernate 3 but cannot use annotations at this time. I’ve attached copies of HBM, DAO etc below. — Thank you in Advance

When attempting to delete data from tables in Parent/Child relationship I get the following error:

Testcase: testDelete(com.dressbarn.imbo.model.data.hibernate.dao.CharityTransferDAOTest):        Caused an ERROR
Hibernate flushing: Could not execute JDBC batch update; uncategorized SQLException for SQL [update RMS12.DRS_CHARITY_TRANSFER_ITEM set TSF_NO=null, TSF_SEQ_NO=null where TSF_NO=?]; SQL state [72000]; error code [1407]; ORA-01407: cannot update ("RMS12"."DRS_CHARITY_TRANSFER_ITEM"."TSF_NO") to NULL
; nested exception is java.sql.BatchUpdateException: ORA-01407: cannot update ("RMS12"."DRS_CHARITY_TRANSFER_ITEM"."TSF_NO") to NULL

org.springframework.jdbc.UncategorizedSQLException: Hibernate flushing: Could not execute JDBC batch update; uncategorized SQLException for SQL [update RMS12.DRS_CHARITY_TRANSFER_ITEM set TSF_NO=null, TSF_SEQ_NO=null where TSF_NO=?]; SQL state [72000]; error code [1407]; ORA-01407: cannot update ("RMS12"."DRS_CHARITY_TRANSFER_ITEM"."TSF_NO") to NULL
; nested exception is java.sql.BatchUpdateException: ORA-01407: cannot update ("RMS12"."DRS_CHARITY_TRANSFER_ITEM"."TSF_NO") to NULL

Caused by: java.sql.BatchUpdateException: ORA-01407: cannot update ("RMS12"."DRS_CHARITY_TRANSFER_ITEM"."TSF_NO") to NULL

        at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:498)
        at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:12368)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
        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 org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:578)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:314)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)
        at com.dressbarn.imbo.model.data.hibernate.dao.CharityTransferDAO$$EnhancerByCGLIB$$6a21cd58.delete(<generated>)
        at com.dressbarn.imbo.model.data.hibernate.dao.CharityTransferDAOTest.testDelete(CharityTransferDAOTest.java:112)
        at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)

My tables are:

Parent:

CREATE TABLE DRS_CHARITY_TRANSFER
(
  TSF_NO          NUMBER(10)                    NOT NULL Primary Key,
  FROM_LOC        NUMBER(10),
  CHARITY_LOC_ID  NUMBER(10),
  STATUS          VARCHAR2(1 CHAR),
  CREATE_DATE     DATE,
  EXT_REF_NO      VARCHAR2(30 CHAR),
  COMMENT_DESC    VARCHAR2(2000 CHAR),
  USER_ID         VARCHAR2(30 CHAR)
)

Child:

CREATE TABLE DRS_CHARITY_TRANSFER_ITEM
 (
  TSF_NO      NUMBER(10)  NOT NULL PRIMARY KEY,
  ITEM        VARCHAR2(25 BYTE)  NOT NULL PRIMARY KEY,
  TSF_SEQ_NO  INTEGER,
  TSF_QTY     INTEGER
)

HBM XML

<hibernate-mapping package="com.dressbarn.imbo.model.data.hibernate.transfer" schema="RMS12">
   <class name="CharityTransfer" table="DRS_CHARITY_TRANSFER">
       <id name="transferNumber" column="TSF_NO" unsaved-value="undefined">

       </id>
       <property column="FROM_LOC" length="10" name="fromLocation" type="java.lang.Long"/>
       <property column="CHARITY_LOC_ID" length="10" name="toCharityLocId" type="java.lang.Long"/>
       <property column="STATUS" name="status" type="string"/>
       <property column="EXT_REF_NO" name="documentNumber" type="string"/>
       <property column="COMMENT_DESC" name="comment" type="string"/>
       <property column="CREATE_DATE" name="createDate" type="string"/>
       <property column="USER_ID" name="userId" type="string"/>
    <list name="charityTransferItemList" cascade="all-delete-orphan" lazy="false">
        <key column="TSF_NO" />
        <list-index column="TSF_SEQ_NO"/>
        <one-to-many class="CharityTransferItem" />
    </list>
</class>

<class name="CharityTransferItem" table="DRS_CHARITY_TRANSFER_ITEM">
    <id name="item" column="TSF_NO" unsaved-value="undefined">

    </id>
    <property column="ITEM" name="item" type="string"/>
    <property column="TSF_SEQ_NO" length="10" name="sequence" type="integer"/>
    <property column="TSF_QTY" length="12" name="quantity" type="long"/>
</class>

DAO

public class CharityTransferDAO extends HibernateDaoSupport implements ICharityTransfer {

   public void delete(CharityTransfer charityTransfer) throws IMADataException {
       try {
         getSessionFactory()
                 .getCurrentSession()
                 .delete(charityTransfer);
      }
      catch (HibernateException e) {
        throw new IMADataException("failed to delete charity shipping information", e);
      }    
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T23:47:23+00:00Added an answer on May 11, 2026 at 11:47 pm

    I encountered this error all the time.

    Just put an inverse=”true” on the relationship and your problem will go away!

    <list name="charityTransferItemList" inverse="true" cascade="all-delete-orphan" lazy="false" >
            <key column="TSF_NO" />
            <list-index column="TSF_SEQ_NO"/>
            <one-to-many class="CharityTransferItem" />
        </list>
    

    Basically the inverse will tell hibernate the child cannot exist without a parent, thereby causing hibernate to delete the child.

    Having said that, you’ll also need to remove the charityTransfer object from the collection in the parent as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've deleted some records from a table in a SQL Server database. The IDs
If all tables I want to delete from have the column gamer_id can i
I would like to know the best way to delete records from a live
I have a datalist with a OnDeleteCommand=Delete_Command. I want the delete a record with
I want to delete foo() if foo() isn't called from anywhere.
I erroneously delete all the rows from a MS SQL 2000 table that is
I want to delete all but the 4 newest directories in my parent directory.
I m trying to delete a record from a SQLiteDB via Android Application,This is
What is the best way to delete a database record using LINQ when I
Since DBs do not reuse numbers of deleted records it is possible to run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.