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.  [ 2 posts ] 
Author Message
 Post subject: hibernate attempts to update row to be deleted
PostPosted: Thu Apr 22, 2010 3:58 am 
Newbie

Joined: Wed Nov 25, 2009 11:35 am
Posts: 17
Hi everybody.
I've ran into a strange problem. I have simple relation many-to-one between Item and Claim:

Code:
<class dynamic-update="true" name="Rmtitem" table="RmtItem">
     <many-to-one class="Rmtclaim" name="rircintn" column="rircintn"/>
     ...
</class>


When I try to execute:
Code:
      Object claim = session.load(Rmtclaim.class, Integer.valueOf(375208));
      Object item = session.load(Rmtitem.class, Integer.valueOf(325122));
      session.delete(claim);
      session.delete(item);
      session.flush();

Exception is trown:
Code:
Hibernate: update RmtItem set rircintn=? where riintn=?
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
        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:237)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
        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 test.Tester.main(Tester.java:57)
Caused by: java.sql.BatchUpdateException: ORA-01407: cannot update ("ARE_RQ73"."RMTITEM"."RIRCINTN") to NULL

        at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
        at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4337)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
        ... 6 more
Java Result: 1

Why hibernate attempts to update record to be deleted?
If order is
Code:
      session.delete(item);
      session.delete(claim);

then test passes.


Top
 Profile  
 
 Post subject: Re: hibernate attempts to update row to be deleted
PostPosted: Fri Apr 23, 2010 6:21 pm 
Newbie

Joined: Fri Sep 29, 2006 6:35 pm
Posts: 6
Really need more info to say for sure, but I suspect that Item doesn't like a null Claim reference, and you're:
a) deleting things in the wrong order; and/or
b) telling it to delete too much (i.e., don't explicitly delete the Item, just the Claim).

Look at your database schema carefully and set cascadeappropriately in the many-to-onetag.
Then perhaps you can simply delete the Claim and let the database delete the associated Items.


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

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.