-->
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: Deletion exception
PostPosted: Wed May 26, 2010 11:49 am 
Newbie

Joined: Mon Feb 02, 2009 5:31 pm
Posts: 8
Hi,

I am trying to delete an object within a manual cascade code and I get a Key constrain may not be Null but I made sure it could be , I delete those items at the very last just before the commit():

Caused by: java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Column 'k_CLOCKREF' cannot be null"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1492)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 77 more


XML :

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//hibernate/Hibernate DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="database.items.Port" table="PORT">
<id name="nPortID" column="PORT_ID">
<generator class="native"/>
</id>

<property name="strPortName"/>
<property name="strComment"/>
<property name="nOnline"/>
<property name="nStatic"/>
<property name="nClockRefSeq"/>
<property name="nPortType"/>

<many-to-one name="theCim" cascade="none" class="database.items.CIM">
<column name="CIM_ID" not-null="false"/>
</many-to-one>

<many-to-one name="theE1InternalNetwork" cascade="none" class="database.items.E1InternalNetwork">
<column name="K_E1IINTNET" not-null="false"/>
</many-to-one>

<many-to-one name="TheClockRef" cascade="none" class="database.items.ClockRef">
<column name="k_CLOCKREF" not-null="false"/>
</many-to-one>

<set name="hsPortSetup">
<key column="PORT_ID" />
<one-to-many class="database.items.PortSetup" />
</set>

<set name="hsT6Radio">
<key column="PORT_ID" />
<one-to-many class="database.items.T6Radio" />
</set>

<set name="hsPortReplication">
<key column="PORT_ID" />
<one-to-many class="database.items.PortReplication" />
</set>

<set name="hsChildPort" cascade="all-delete-orphan">
<key column="TheParentPort" />
<one-to-many class="database.items.Port" />
</set>

<many-to-one name="TheParentPort" cascade="none">
<column name="TheParentPort" not-null="false" />
</many-to-one>

<many-to-one name="TheModemPort" cascade="none">
<column name="TheModemPort" not-null="false" />
</many-to-one>

<set name="hsMapping">
<key column="PORT_ID" />
<one-to-many class="database.items.Mapping" />
</set>

<set name="hsIOReplication">
<key column="PORT_ID" />
<one-to-many class="database.items.IOReplication" />
</set>


</class>
</hibernate-mapping>

the code :

public void deleteCascade(Session aSession){

if(this.gethsChildPort().size() > 0 ){
for(int cptDel = 0; cptDel < this.gethsChildPort().size(); cptDel ++){
((Port)this.gethsChildPort().toArray()[cptDel]).deleteCascade(aSession);
}
}
aSession.delete(this);
}


Help please!


Top
 Profile  
 
 Post subject: Re: Deletion exception
PostPosted: Wed May 26, 2010 12:04 pm 
Newbie

Joined: Mon Feb 02, 2009 5:31 pm
Posts: 8
It looks if I do the delete in two separated transaction it works.

i.e. delete everything else (clockRef, E1Internal) then I commit and then I delete the port class and it works...


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.