Hi,
Before all, thanks for you attention :)) !
I'm using
hibernate2.1 with
Oracle9 and my program is a
stand alone application.
My problem:
So, i have 2 objects: TransoraDetail and TransoraAddModifyDetail;
The relationschip betwen the 2 objects it's one to multi (unidirectionel);
a TransoraDetail can have one or moore TransoraAddModifyDetail's
TransoraDetail 1->>------------------------1,* TransoraAddModifyDetail
Now, when i delete a TransoraAddModifyDetail object i want that
on the base to be made a delete request but a update request is made.
So, here is the code;
Code:
TransoraAddmodify master;
TransoraAddmodifyDetail detail;
TransoraAddmodifyDetailPK detailPK;//primaryKey
master.removeTransoraAddmodifyDetail(detailPk);
session.update(master);
session.flush();
session.connection().commit();
So, when i do a commit the sql request who is made is a update on TransoraAddmodifyDetail table
but not a delete that i was waitong for.
The request is :
Code:
Hibernate: update TRANSORA_ADDMODIFY_DETAILS set INTERCHANGE_CONTRACT=null, LN_RECIPIENT=null,
NC_LN_RECIPIENT_COD_TYP=null, LN=null, NC_LN_COD_TYP=null, PN=null, NC_PN_COD_TYP=null, PV=null,
NC_TARGET_MARKET=null, TYPE=null, REQUEST_ID=null where INTERCHANGE_CONTRACT=? and LN_RECIPIENT=?
and NC_LN_RECIPIENT_COD_TYP=? and LN=? and NC_LN_COD_TYP=? and PN=? and NC_PN_COD_TYP=? and PV=?
the entire hibernate message is:
Code:
Hibernate: select transorade0_.INTERCHANGE_CONTRACT as INTERCHA1_0_, transorade0_.LN_RECIPIENT as LN_RECIP2_0_, transorade0_.NC_LN_RECIPIENT_COD_TYP as NC_LN_RE3_0_, transorade0_.LN as LN0_, transorade0_.NC_LN_COD_TYP as NC_LN_CO5_0_, transorade0_.PN as PN0_, transorade0_.NC_PN_COD_TYP as NC_PN_CO7_0_, transorade0_.PV as PV0_, transorade0_.DT_STATUS_ADDMODIFY as DT_STATU9_0_, transorade0_.STATUS_ADDMODIFY as STATUS_10_0_, transorade0_.DT_STATUS_LINK as DT_STAT11_0_, transorade0_.STATUS_LINK as STATUS_12_0_, transorade0_.DT_STATUS_PUBLICATION as DT_STAT13_0_, transorade0_.STATUS_PUBLICATION as STATUS_14_0_ from TRANSORA_DETAILS transorade0_ where transorade0_.INTERCHANGE_CONTRACT=? and transorade0_.LN_RECIPIENT=? and transorade0_.NC_LN_RECIPIENT_COD_TYP=? and transorade0_.LN=? and transorade0_.NC_LN_COD_TYP=? and transorade0_.PN=? and transorade0_.NC_PN_COD_TYP=? and transorade0_.PV=?
Hibernate: select transoraad0_.INTERCHANGE_CONTRACT as INTERCHA1___, transoraad0_.LN_RECIPIENT as LN_RECIP2___, transoraad0_.NC_LN_RECIPIENT_COD_TYP as NC_LN_RE3___, transoraad0_.LN as LN__, transoraad0_.NC_LN_COD_TYP as NC_LN_CO5___, transoraad0_.PN as PN__, transoraad0_.NC_PN_COD_TYP as NC_PN_CO7___, transoraad0_.PV as PV__, transoraad0_.NC_TARGET_MARKET as NC_TARGE9___, transoraad0_.TYPE as TYPE__, transoraad0_.REQUEST_ID as REQUEST_ID__, transoraad0_.INTERCHANGE_CONTRACT as INTERCHA1_0_, transoraad0_.LN_RECIPIENT as LN_RECIP2_0_, transoraad0_.NC_LN_RECIPIENT_COD_TYP as NC_LN_RE3_0_, transoraad0_.LN as LN0_, transoraad0_.NC_LN_COD_TYP as NC_LN_CO5_0_, transoraad0_.PN as PN0_, transoraad0_.NC_PN_COD_TYP as NC_PN_CO7_0_, transoraad0_.PV as PV0_, transoraad0_.NC_TARGET_MARKET as NC_TARGE9_0_, transoraad0_.TYPE as TYPE0_, transoraad0_.REQUEST_ID as REQUEST_ID0_, transoraad0_.DT_REQUEST as DT_REQUEST0_, transoraad0_.RESPONSE_ID as RESPONS13_0_, transoraad0_.DT_RESPONSE as DT_RESP14_0_, transoraad0_.MESSAGE as MESSAGE0_, transoraad0_.STATUS as STATUS0_ from TRANSORA_ADDMODIFY_DETAILS transoraad0_ where transoraad0_.INTERCHANGE_CONTRACT=? and transoraad0_.LN_RECIPIENT=? and transoraad0_.NC_LN_RECIPIENT_COD_TYP=? and transoraad0_.LN=? and transoraad0_.NC_LN_COD_TYP=? and transoraad0_.PN=? and transoraad0_.NC_PN_COD_TYP=? and transoraad0_.PV=?
Hibernate: update TRANSORA_ADDMODIFY_DETAILS set INTERCHANGE_CONTRACT=null, LN_RECIPIENT=null, NC_LN_RECIPIENT_COD_TYP=null, LN=null, NC_LN_COD_TYP=null, PN=null, NC_PN_COD_TYP=null, PV=null, NC_TARGET_MARKET=null, TYPE=null, REQUEST_ID=null where INTERCHANGE_CONTRACT=? and LN_RECIPIENT=? and NC_LN_RECIPIENT_COD_TYP=? and LN=? and NC_LN_COD_TYP=? and PN=? and NC_PN_COD_TYP=? and PV=?
HibernateException - Could not execute JDBC batch update
net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:129)
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2385)
net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2338)
net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
com.influe.asp.cds.entities.products.distributions.transora.detail.DumbTestTransoraDetail.deleteTransoraAddModifyDetail(DumbTestTransoraDetail.java:145)
com.influe.asp.cds.entities.products.distributions.transora.detail.DumbTestTransoraDetail.main(DumbTestTransoraDetail.java:97)
Exception - java.sql.BatchUpdateException: ORA-01407: impossible de mettre à jour ("CDS162"."TRANSORA_ADDMODIFY_DETAILS"."INTERCHANGE_CONTRACT") avec NULL
The xml files:
TransoraAddmodify.hbm.xml
Code:
<class
name="com.influe.asp.cds.entities.products.distributions.transora.detail.hibernate.TransoraDetail"
table="TRANSORA_DETAILS"
>
<composite-id name="pk" class="com.influe.asp.cds.entities.products.distributions.transora.detail.hibernate.TransoraDetailPK">
<key-property name="INTERCHANGE_CONTRACT" column="INTERCHANGE_CONTRACT" type="java.lang.String"/>
<key-property name="LN_RECIPIENT" column="LN_RECIPIENT" type="java.lang.String"/>
<key-property name="NC_LN_RECIPIENT_COD_TYP" column="NC_LN_RECIPIENT_COD_TYP" type="java.lang.String"/>
<key-property name="LN" column="LN" type="java.lang.String"/>
<key-property name="NC_LN_COD_TYP" column="NC_LN_COD_TYP" type="java.lang.String"/>
<key-property name="PN" column="PN" type="java.lang.String"/>
<key-property name="NC_PN_COD_TYP" column="NC_PN_COD_TYP" type="java.lang.String"/>
<key-property name="PV" column="PV" type="java.lang.String"/>
</composite-id>
.......................
<!-- associations -->
<!-- uni-directional one-to-many association to TransoraAddmodifyDetail -->
<map
name="transoraAddmodifyDetails"
lazy="true"
cascade = "all-delete-orphan"
>
<key>
<column name="INTERCHANGE_CONTRACT" />
<column name="LN_RECIPIENT" />
<column name="NC_LN_RECIPIENT_COD_TYP" />
<column name="LN" />
<column name="NC_LN_COD_TYP" />
<column name="PN" />
<column name="NC_PN_COD_TYP" />
<column name="PV" />
</key>
<composite-index class="com.influe.asp.cds.entities.products.distributions.transora.addmodify.hibernate.TransoraAddmodifyDetailPK" >
<key-property name="NC_TARGET_MARKET" column="NC_TARGET_MARKET" type="java.lang.String"/>
<key-property name="TYPE" column="TYPE" type="java.lang.String"/>
<key-property name="REQUEST_ID" column="REQUEST_ID" type="java.lang.String"/>
</composite-index>
<one-to-many
class="com.influe.asp.cds.entities.products.distributions.transora.addmodify.hibernate.TransoraAddmodifyDetail"
/>
</map>
TransoraAddmodifyDetail.hbm.xml
Code:
<class
name="com.influe.asp.cds.entities.products.distributions.transora.addmodify.hibernate.TransoraAddmodifyDetail"
table="TRANSORA_ADDMODIFY_DETAILS"
>
<composite-id name="pk" class="com.influe.asp.cds.entities.products.distributions.transora.addmodify.hibernate.TransoraAddmodifyDetailPK">
<key-property name="INTERCHANGE_CONTRACT" column="INTERCHANGE_CONTRACT" type="java.lang.String"/>
<key-property name="LN_RECIPIENT" column="LN_RECIPIENT" type="java.lang.String"/>
<key-property name="NC_LN_RECIPIENT_COD_TYP" column="NC_LN_RECIPIENT_COD_TYP" type="java.lang.String"/>
<key-property name="LN" column="LN" type="java.lang.String"/>
<key-property name="NC_LN_COD_TYP" column="NC_LN_COD_TYP" type="java.lang.String"/>
<key-property name="PN" column="PN" type="java.lang.String"/>
<key-property name="NC_PN_COD_TYP" column="NC_PN_COD_TYP" type="java.lang.String"/>
<key-property name="PV" column="PV" type="java.lang.String"/>
<key-property name="NC_TARGET_MARKET" column="NC_TARGET_MARKET" type="java.lang.String"/>
<key-property name="TYPE" column="TYPE" type="java.lang.String"/>
<key-property name="REQUEST_ID" column="REQUEST_ID" type="java.lang.String"/>
</composite-id>
<property
name="DT_REQUEST"
type="java.sql.Timestamp"
column="DT_REQUEST"
length="7"
/>
<property
name="RESPONSE_ID"
type="java.lang.String"
column="RESPONSE_ID"
length="255"
/>
<property
name="DT_RESPONSE"
type="java.sql.Timestamp"
column="DT_RESPONSE"
length="7"
/>
<property
name="MESSAGE"
type="java.lang.String"
column="MESSAGE"
length="255"
/>
<property
name="STATUS"
type="java.lang.Integer"
column="STATUS"
length="1"
/>
</class>
Thank's