You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "McCaffrey, John G." <Jo...@kraft.com> on 2003/07/09 00:12:22 UTC
Rollback not happening
hmmm. I must be missing something, but I thought if I called
persistanceBroker.beginTransaction();
persistanceBroker.store(brokerVO);
and if there was an exception and persistanceBroker.commitTransaction();
never gets called, then the data should not be in the database.
I am storing a BrokerVO that has N BusinessContact objects, and if one of
the businesContacts fails to insert, I want the whole transaction to
rollback. I am not sure what I am doing wrong here. If any part of the
transaction fails (I am inserting into three tables), I want all of the data
to rollback.
<snip>
<class-descriptor class="com.kraft.esi.msf.common.db.dsna.BrokerVO"
schema="&schema;" table="brkr">
<field-descriptor id="1" name="brkrNbr" column="BP_NBR"
jdbc-type="DECIMAL" primarykey="true"/>
<field-descriptor id="2" name="vendNbr" column="AP_VNDR_NBR"
jdbc-type="VARCHAR" />
<field-descriptor id="3" name="brkrEffStrtDate"
column="EFCT_STRT_DT" jdbc-type="DATE"
conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFi
eldConversion"/>
<field-descriptor id="4" name="brkrEffEndDate"
column="EFCT_END_DT" jdbc-type="DATE"
conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFi
eldConversion"/>
<field-descriptor id="5" name="brkrComment" column="CMNT"
jdbc-type="VARCHAR"/>
<reference-descriptor name="busnPtnrVO"
class-ref="com.kraft.esi.msf.common.db.dsna.BusnPtnrVO" auto-retrieve="true"
auto-update="true" auto-delete="true">
<foreignkey field-id-ref="1"/>
</reference-descriptor>
<reference-descriptor name="apVndrVO"
class-ref="com.kraft.esi.msf.common.db.dsna.ApVndrVO" auto-retrieve="true"
auto-update="false" auto-delete="false">
<foreignkey field-id-ref="2"/>
</reference-descriptor>
<!-- -->
<collection-descriptor name="businessContacts"
element-class-ref="com.kraft.esi.msf.common.db.dsna.BpCntctVO"
auto-retrieve="true" auto-update="true"
auto-delete="true" orderby="cntctTypeCode" sort="ASC"
proxy="false" >
<inverse-foreignkey field-id-ref="1"/>
</collection-descriptor>
</class-descriptor>
<snip>
I am using WebSphere transaction manager factory, and
ConnectionFactoryManagedImpl.
any help would be greatly appreciated.
-John
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Rollback not happening
Posted by cw...@insect.com.
John,
Do you call
broker.abortTransaction() ;
when you catch the exception.
-chris worley
> hmmm. I must be missing something, but I thought if I called
> persistanceBroker.beginTransaction();
> persistanceBroker.store(brokerVO);
> and if there was an exception and persistanceBroker.commitTransaction();
> never gets called, then the data should not be in the database.
>
> I am storing a BrokerVO that has N BusinessContact objects, and if one of
> the businesContacts fails to insert, I want the whole transaction to
> rollback. I am not sure what I am doing wrong here. If any part of the
> transaction fails (I am inserting into three tables), I want all of the
> data
> to rollback.
>
>
> <snip>
> <class-descriptor class="com.kraft.esi.msf.common.db.dsna.BrokerVO"
> schema="&schema;" table="brkr">
> <field-descriptor id="1" name="brkrNbr" column="BP_NBR"
> jdbc-type="DECIMAL" primarykey="true"/>
> <field-descriptor id="2" name="vendNbr" column="AP_VNDR_NBR"
> jdbc-type="VARCHAR" />
>
> <field-descriptor id="3" name="brkrEffStrtDate"
> column="EFCT_STRT_DT" jdbc-type="DATE"
>
> conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFi
> eldConversion"/>
> <field-descriptor id="4" name="brkrEffEndDate"
> column="EFCT_END_DT" jdbc-type="DATE"
>
> conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFi
> eldConversion"/>
> <field-descriptor id="5" name="brkrComment" column="CMNT"
> jdbc-type="VARCHAR"/>
>
> <reference-descriptor name="busnPtnrVO"
> class-ref="com.kraft.esi.msf.common.db.dsna.BusnPtnrVO"
> auto-retrieve="true"
> auto-update="true" auto-delete="true">
> <foreignkey field-id-ref="1"/>
> </reference-descriptor>
>
> <reference-descriptor name="apVndrVO"
> class-ref="com.kraft.esi.msf.common.db.dsna.ApVndrVO" auto-retrieve="true"
> auto-update="false" auto-delete="false">
> <foreignkey field-id-ref="2"/>
> </reference-descriptor>
> <!-- -->
> <collection-descriptor name="businessContacts"
> element-class-ref="com.kraft.esi.msf.common.db.dsna.BpCntctVO"
> auto-retrieve="true" auto-update="true"
> auto-delete="true" orderby="cntctTypeCode" sort="ASC"
> proxy="false" >
> <inverse-foreignkey field-id-ref="1"/>
> </collection-descriptor>
>
> </class-descriptor>
>
> <snip>
>
> I am using WebSphere transaction manager factory, and
> ConnectionFactoryManagedImpl.
>
> any help would be greatly appreciated.
>
> -John
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Rollback not happening
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi,
> I am using WebSphere transaction manager factory, and
> ConnectionFactoryManagedImpl.
if you are running in an managed environment use
declarative or programmatic transaction of your
appServer (don't use the OJB tx demarcation
e.g beginTransaction(), ...).
How do you use OJB - within session beans?
If you don't run in a managed environment
and you want to use OJB tx-demarcation, don't
set 'ConnectionFactoryManagedImpl'.
regards,
Armin
----- Original Message -----
From: "McCaffrey, John G." <Jo...@kraft.com>
To: "'OJB Users List'" <oj...@db.apache.org>
Sent: Wednesday, July 09, 2003 12:12 AM
Subject: Rollback not happening
> hmmm. I must be missing something, but I thought if I called
> persistanceBroker.beginTransaction();
> persistanceBroker.store(brokerVO);
> and if there was an exception and
persistanceBroker.commitTransaction();
> never gets called, then the data should not be in the database.
>
> I am storing a BrokerVO that has N BusinessContact objects, and if one
of
> the businesContacts fails to insert, I want the whole transaction to
> rollback. I am not sure what I am doing wrong here. If any part of the
> transaction fails (I am inserting into three tables), I want all of
the data
> to rollback.
>
>
> <snip>
> <class-descriptor class="com.kraft.esi.msf.common.db.dsna.BrokerVO"
> schema="&schema;" table="brkr">
> <field-descriptor id="1" name="brkrNbr" column="BP_NBR"
> jdbc-type="DECIMAL" primarykey="true"/>
> <field-descriptor id="2" name="vendNbr" column="AP_VNDR_NBR"
> jdbc-type="VARCHAR" />
>
> <field-descriptor id="3" name="brkrEffStrtDate"
> column="EFCT_STRT_DT" jdbc-type="DATE"
>
>
conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDa
teFi
> eldConversion"/>
> <field-descriptor id="4" name="brkrEffEndDate"
> column="EFCT_END_DT" jdbc-type="DATE"
>
>
conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDa
teFi
> eldConversion"/>
> <field-descriptor id="5" name="brkrComment" column="CMNT"
> jdbc-type="VARCHAR"/>
>
> <reference-descriptor name="busnPtnrVO"
> class-ref="com.kraft.esi.msf.common.db.dsna.BusnPtnrVO"
auto-retrieve="true"
> auto-update="true" auto-delete="true">
> <foreignkey field-id-ref="1"/>
> </reference-descriptor>
>
> <reference-descriptor name="apVndrVO"
> class-ref="com.kraft.esi.msf.common.db.dsna.ApVndrVO"
auto-retrieve="true"
> auto-update="false" auto-delete="false">
> <foreignkey field-id-ref="2"/>
> </reference-descriptor>
> <!-- -->
> <collection-descriptor name="businessContacts"
> element-class-ref="com.kraft.esi.msf.common.db.dsna.BpCntctVO"
> auto-retrieve="true" auto-update="true"
> auto-delete="true" orderby="cntctTypeCode" sort="ASC"
> proxy="false" >
> <inverse-foreignkey field-id-ref="1"/>
> </collection-descriptor>
>
> </class-descriptor>
>
> <snip>
>
> I am using WebSphere transaction manager factory, and
> ConnectionFactoryManagedImpl.
>
> any help would be greatly appreciated.
>
> -John
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org