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!
|