db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: Auto-Commit and Rollback does not work as documented in "Repository File"
Date Wed, 06 Oct 2004 22:22:38 GMT
Hi Ajitesch,

first problem in your example is that the jcd-alias is not unique. The 
jcd-alias have to be unique across all used jdbc-connection-descriptor.

 > My expectation was that the 2nd one would save the data in the DB as
 > soon as
 > PB.store() is called whereas the 1st one would commit the data in to the
 > DB only when Tx.commit() is called.

Sorry, it seems that the documentation isn't clear
http://db.apache.org/ojb/docu/guides/repository.html#useAutoCommit

When you use useAutoCommit="1" OJB set autoCommit false when you start a 
PB-tx and restore old state (true) after PB-tx commit.
But we strongly recommend not to store/delete objects without PB-tx (or 
JTA tx in managed environments).
E.g. if you want to store an complex object graph (A->B->C->D) and 
autoCommit is true and you do PB.store(A), then OJB internally do 
PB.store(D), PB.store(C) ... (with proper auto-xxx settings in reference 
mapping) and D and C was written to DB immediately (autoCommit is true). 
When storing B an error occur, but now OJB can't rollback D and C.
That's the reason why latest OJB versions log a warning when user try to 
store/delete objects without a running tx.

If you use useAutoCommit="2", then autoCommit was explicit set false, 
but finally there is no difference in handling on PB level. So if you 
don't have problems with default setting there's no reason to change it.


regards,
Armin


Ajitesh Das wrote:

> Again is this a bug? Or I am missing something.
> 
> The followings are snippets of two jdbc descriptors defined in two
> different respository xmls.
> 
>     <jdbc-connection-descriptor  platform="MsSQLServer"
>          jcd-alias="zdb"
>          default-connection="false"
>          jdbc-level="2.0"
>          driver="net.sourceforge.jtds.jdbc.Driver"
>          protocol="jdbc"
>          subprotocol="jtds:sqlserver"
>          dbalias="//localhost:1433/adb;user=aaa;password=ppp;"
>          username="aaa"
>          password="ppp"
> 
>          <!-- useAutoCommit="1" which is default -->
>     />
> 
> AND 
> 
>     <jdbc-connection-descriptor  platform="MsSQLServer"
>          jcd-alias="zdb"
>          default-connection="false"
>          jdbc-level="2.0"
>          driver="net.sourceforge.jtds.jdbc.Driver"
>          protocol="jdbc"
>          subprotocol="jtds:sqlserver"
>          dbalias="//localhost:1433/adb;user=aaa;password=ppp;"
>          username="aaa"
>          password="ppp"
>          useAutoCommit="2"
>     />
> 
> Please note the following difference:
>   One uses useAutoCommit="2" and other uses useAutoCommit="1" as a
> default.
> 
> My expectation was that the 2nd one would save the data in the DB as
> soon as 
> PB.store() is called whereas the 1st one would commit the data in to the
> DB only when Tx.commit() is called. 
> 
> But, in reality, both  of them are showing the "1st's case" behavior i.e
> one would commit the data in to the DB only when Tx.commit() is called.
> [Note in 1st case, I have used useAutoCommit="1"] and this seems
> misaligned with the claim of the documentation.
> 
> Thanks
>  
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message