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 Steve Clark <sc...@euler.cr.usgs.gov> on 2004/04/29 00:49:46 UTC
Second try: (ODMG) Transaction.abort() vs. object rollback
Does anybody have any insight on the post-abort state of persistent
objects? I'm in a bit of a bind if my understanding of this is
correct.
thanks,
-steve
> From: "Steve Clark" <sc...@euler.cr.usgs.gov>
> To: ojb-user@db.apache.org
> Subject: (ODMG) Transaction.abort() vs. object rollback
> Date: Tue, 27 Apr 2004 13:20:54 -0600
The way I read the Javadocs, if I make some changes to persistent
objects which are locked to an ODMG Transaction, and then
Transaction.commit() fails, e.g. due to a database constraint
violation, then the objects in memory should be rolled back to their
state prior to the Transaction. Is my understanding correct?
I am seeing the following behavior:
tx1.begin();
parent = fetchParent();
tx1.commit();
assert(parent.getChildren().size() == 1);
tx2.begin();
child = new Child();
child.setSomeAttributeToInvalidValue();
tx.lock(parent, WRITE);
parent.addChild(child);
try {
tx2.commit();
}
catch TransactionAbortedException {
assert(parent.getChildren().size() == 2);
}
My child object contains a value which violates a database
constraint. On commit(), the Transaction, as expected, throws
TransactionAbortedException. But the new Child object is still in
the parent's collection of children, so future Transactions
involving this parent will fail (including deletePersistent(),
which attempts to insert the missing Child, not realizing that it
will be immediately deleted).
Is this the correct behavior?
Should this be the expected behavior?
If the answer to both questions is yes, then I think the Javadocs need
some clarification.
Finally, if this is the correct behavior, what are others doing to
address this situation?
I'm using CVS HEAD as of a week or so ago.
thanks,
--
Steve Clark
Technology Applications Team
Natural Resources Research Center/USGS
sclark@support.tat.fws.gov
(970)226-9291
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
--
Steve Clark
Technology Applications Team
Natural Resources Research Center/USGS
sclark@support.tat.fws.gov
(970)226-9291
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Second try: (ODMG) Transaction.abort() vs. object rollback
Posted by Matthias Laube <ml...@gmx.de>.
Armin Waibel wrote:
>
>
> Steve Clark wrote:
>
>> Steve> So what are others doing about this situation? Does
>> Steve> everybody write their own snapshot/rollback code?
>>
>> Armin> You can simply request the object again after abort.
>>
>> Does Transaction.abort() remove all of its registered objects from the
>> cache? If so, then this solution will work fine for me.
>>
>
> yep, this should happend.
>
> Armin
>
>> -steve
>>
>> ---------------------------------------------------------------------
>> 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
>
>
Furthermore:
Only objects that were locked by the aborted tx AND changed are removed
from the cache.
If the invalid object is contained in a collection of an object that was
not locked or not changed the changed version of the object remains in
the cached collection.
I would prefer the restore - solution, which worked in rc4.
---------------------------------------------------------------------
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: Second try: (ODMG) Transaction.abort() vs. object rollback
Posted by Matthias Laube <ml...@gmx.de>.
Armin Waibel wrote:
>
>
> Steve Clark wrote:
>
>> Steve> So what are others doing about this situation? Does
>> Steve> everybody write their own snapshot/rollback code?
>>
>> Armin> You can simply request the object again after abort.
>>
>> Does Transaction.abort() remove all of its registered objects from the
>> cache? If so, then this solution will work fine for me.
>>
>
> yep, this should happend.
>
> Armin
>
>> -steve
>>
>> ---------------------------------------------------------------------
>> 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
>
>
In my tests with OJB 1.0 RC6 ODMG after abort I got the following results:
- the DB-Transaction is rolled back.
- When I have called flush before commit the changed object is NOT
removed from the cache.
I would prefer the restore - solution, which worked in rc4.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Second try: (ODMG) Transaction.abort() vs. object rollback
Posted by Armin Waibel <ar...@apache.org>.
Steve Clark wrote:
> Steve> So what are others doing about this situation? Does
> Steve> everybody write their own snapshot/rollback code?
>
> Armin> You can simply request the object again after abort.
>
> Does Transaction.abort() remove all of its registered objects from the
> cache? If so, then this solution will work fine for me.
>
yep, this should happend.
Armin
> -steve
>
> ---------------------------------------------------------------------
> 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: client-server Object Caching
Posted by Armin Waibel <ar...@apache.org>.
Hi again,
Amol Pophale wrote:
...
>>So you use PB-api only for read-only operations and
>>persist objects via
>>the server - right?
>>And on the server you don't use OJB?
>>Can you describe a little more?
>
> YES U ARE ABSOLUTELY CORRECT I AM MOT USING OJB ON
> SERVER SIDE.
>
...
> I CANT FIRE QUERIES EVERYTIME ON DATABSE DIRECTLY
> BECAUSE I WANT TO USE CACHE TO IMPROVE PERFORMANCE BUT
> I WANT OT KNOW HOW CLIENT CAN KNOW THAT DATABSE OBJECT
> IS CHANGED SO IT CAN REMOVE THAT OBJECT FROM CACHE.
> I HAVE ONE SOLUTION, WHEN SERVER UPDATES DATABSE IT
> SHOULD TELL CLIENT THAT I HAVE UPDATED DATABSE SO
> CLIENT CAN REMOVE THAT OBJECT FROM CACHE.
> HOW DO U FINFD THIS SOLUTION?
Sounds ok for me, if the number of clients is less and the frequency of
updates is low (in other cases you need a very fast intranet and very
performant server nodes ;-)). I don't know a better way.
Be careful with ObjectCache implementations and referenced objects.
Currently the implemetations are quite simple and cache the main object
with all references. Remove only remove the main object, if the same
object was part of a collection of another main object it will not be
removed.
I will start a new ObjectCacheImplementation in near future only holds
Identity objects of referenced objects. Maybe you have to tweak one of
the existing cache implementations. It is possible to refresh referened
objects but this could lead in DB access.
regards,
Armin
> ONE MORE QUESTIONS
> DO U KNOW OTHER TOOL BETTER THAN THIS FOR OBJECT
> RELATIONAL MAPPING?
> I HAVE READ ABOUT TOPLINK FROM ORACLE, COCOBASE,
> HYBERNET BUT I DONT KNOW HOW ARE THEY?
> AND WHAT IS DIFF BETWEEN THEM?
> IF U HAVE ANY INFO PLZ LET ME KNOW
>
>>regards,
>>Armin
>>
>>
>>>This is my problem
>>>
>>>Thanks & Regards
>>>Amol Pophale.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
> ____________________________________________________________
>
>>>Yahoo! Messenger - Communicate instantly..."Ping"
>>>your friends today! Download Messenger Now
>>>http://uk.messenger.yahoo.com/download/index.html
>>>
>>>
>>
> ---------------------------------------------------------------------
>
>>>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
>>
>
>
>
>
>
>
> ____________________________________________________________
> Yahoo! Messenger - Communicate instantly..."Ping"
> your friends today! Download Messenger Now
> http://uk.messenger.yahoo.com/download/index.html
>
> ---------------------------------------------------------------------
> 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: client-server Object Caching
Posted by Guillaume Nodet <gu...@deliasystems.com>.
I think the only way for the client to be aware of
server-side modifications to the database is to use
a distributed cache (OSCache, Swarmcache, jcs, ...).
The other way is, as Armin mentionned, not to
use cache at all on the client.
For other tools to do o/r mapping see
http://c2.com/cgi-bin/wiki?ObjectRelationalToolComparison
Guillaume
-----Message d'origine-----
De : Amol Pophale [mailto:amolrasika@yahoo.com]
Envoyé : mardi 4 mai 2004 12:14
À : OJB Users List
Objet : Re: client-server Object Caching
Hi Armin,
Thanks anyway for the reply
read inline comments with block letters.
Regards,
Amol
--- Armin Waibel <ar...@apache.org> wrote: > Hi
Amol,
>
> I read your previous posts carefully too, but I'm
> not sure that I can help.
>
> Amol Pophale wrote:
> > Hi All,
> > Please read carefully and suggest me solution.
> > I am working with one MNC s/w company.My
> application
> > is web-based client-server application in which
> client
> > and server are on different machines and uses same
> > database. One imp thing one client might connect
> to
> > more than one servers.Each server has one database
> > which may be on server itself or on third machine.
> > These servers stores some data in database.
> > and also send a xml copy of same data on some port
> > to client.web Clint get this data from server in
> the
> > form of xml parses this xml and creates objects
> from
> > that and stores in memory. If there are any
> changes in
> > data server notify client so client can update its
> > in-memory store.[client is not using database
> > directly (jdbc)because firing query on Database
> every
> > time is not feasible with current DB schema]But
> > disadvantage of this is, if clients connect to
> > multiple server [yes, there may be more than one
> > servers]then performance of web-server on client
> > decrease because it store data of all server in
> > memory.
> > Now we redesign the database schema and now client
> > can connect to each server's database directly
> using
> > OJB PersistanceBroker API and get data.
>
> So you use PB-api only for read-only operations and
> persist objects via
> the server - right?
> And on the server you don't use OJB?
> Can you describe a little more?
YES U ARE ABSOLUTELY CORRECT I AM MOT USING OJB ON
SERVER SIDE.
>
> > IN Object
> > cache implementation if there is some data in
> cache
> > and
> > same data get changed by server how clients knows
> this
> > change and cache can be updated?
>
> hmm, I don't recommend to use a distributed cache on
> client side this
> will be overkill if you run more than a few clients.
> If you allow direct
> access from the client to the DB I assume
> client/server/DB run in an
> intranet. Do the client have to recognize changes in
> DB immediately or
> is latency allowed? If not I recommend not cache
> data on client side or
> to use the per broker cache (cache only data within
> a transaction or
> till the PB instance was closed), otherwise you can
> use cached object
> 'timeout' property of the default object cache.
I CANT FIRE QUERIES EVERYTIME ON DATABSE DIRECTLY
BECAUSE I WANT TO USE CACHE TO IMPROVE PERFORMANCE BUT
I WANT OT KNOW HOW CLIENT CAN KNOW THAT DATABSE OBJECT
IS CHANGED SO IT CAN REMOVE THAT OBJECT FROM CACHE.
I HAVE ONE SOLUTION, WHEN SERVER UPDATES DATABSE IT
SHOULD TELL CLIENT THAT I HAVE UPDATED DATABSE SO
CLIENT CAN REMOVE THAT OBJECT FROM CACHE.
HOW DO U FINFD THIS SOLUTION?
ONE MORE QUESTIONS
DO U KNOW OTHER TOOL BETTER THAN THIS FOR OBJECT
RELATIONAL MAPPING?
I HAVE READ ABOUT TOPLINK FROM ORACLE, COCOBASE,
HYBERNET BUT I DONT KNOW HOW ARE THEY?
AND WHAT IS DIFF BETWEEN THEM?
IF U HAVE ANY INFO PLZ LET ME KNOW
>
> regards,
> Armin
>
> > This is my problem
> >
> > Thanks & Regards
> > Amol Pophale.
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
____________________________________________________________
> > Yahoo! Messenger - Communicate instantly..."Ping"
> > your friends today! Download Messenger Now
> > http://uk.messenger.yahoo.com/download/index.html
> >
> >
>
---------------------------------------------------------------------
> > 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
>
____________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
---------------------------------------------------------------------
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: client-server Object Caching
Posted by Amol Pophale <am...@yahoo.com>.
Hi Armin,
Thanks anyway for the reply
read inline comments with block letters.
Regards,
Amol
--- Armin Waibel <ar...@apache.org> wrote: > Hi
Amol,
>
> I read your previous posts carefully too, but I'm
> not sure that I can help.
>
> Amol Pophale wrote:
> > Hi All,
> > Please read carefully and suggest me solution.
> > I am working with one MNC s/w company.My
> application
> > is web-based client-server application in which
> client
> > and server are on different machines and uses same
> > database. One imp thing one client might connect
> to
> > more than one servers.Each server has one database
> > which may be on server itself or on third machine.
> > These servers stores some data in database.
> > and also send a xml copy of same data on some port
> > to client.web Clint get this data from server in
> the
> > form of xml parses this xml and creates objects
> from
> > that and stores in memory. If there are any
> changes in
> > data server notify client so client can update its
> > in-memory store.[client is not using database
> > directly (jdbc)because firing query on Database
> every
> > time is not feasible with current DB schema]But
> > disadvantage of this is, if clients connect to
> > multiple server [yes, there may be more than one
> > servers]then performance of web-server on client
> > decrease because it store data of all server in
> > memory.
> > Now we redesign the database schema and now client
> > can connect to each server's database directly
> using
> > OJB PersistanceBroker API and get data.
>
> So you use PB-api only for read-only operations and
> persist objects via
> the server - right?
> And on the server you don't use OJB?
> Can you describe a little more?
YES U ARE ABSOLUTELY CORRECT I AM MOT USING OJB ON
SERVER SIDE.
>
> > IN Object
> > cache implementation if there is some data in
> cache
> > and
> > same data get changed by server how clients knows
> this
> > change and cache can be updated?
>
> hmm, I don't recommend to use a distributed cache on
> client side this
> will be overkill if you run more than a few clients.
> If you allow direct
> access from the client to the DB I assume
> client/server/DB run in an
> intranet. Do the client have to recognize changes in
> DB immediately or
> is latency allowed? If not I recommend not cache
> data on client side or
> to use the per broker cache (cache only data within
> a transaction or
> till the PB instance was closed), otherwise you can
> use cached object
> 'timeout' property of the default object cache.
I CANT FIRE QUERIES EVERYTIME ON DATABSE DIRECTLY
BECAUSE I WANT TO USE CACHE TO IMPROVE PERFORMANCE BUT
I WANT OT KNOW HOW CLIENT CAN KNOW THAT DATABSE OBJECT
IS CHANGED SO IT CAN REMOVE THAT OBJECT FROM CACHE.
I HAVE ONE SOLUTION, WHEN SERVER UPDATES DATABSE IT
SHOULD TELL CLIENT THAT I HAVE UPDATED DATABSE SO
CLIENT CAN REMOVE THAT OBJECT FROM CACHE.
HOW DO U FINFD THIS SOLUTION?
ONE MORE QUESTIONS
DO U KNOW OTHER TOOL BETTER THAN THIS FOR OBJECT
RELATIONAL MAPPING?
I HAVE READ ABOUT TOPLINK FROM ORACLE, COCOBASE,
HYBERNET BUT I DONT KNOW HOW ARE THEY?
AND WHAT IS DIFF BETWEEN THEM?
IF U HAVE ANY INFO PLZ LET ME KNOW
>
> regards,
> Armin
>
> > This is my problem
> >
> > Thanks & Regards
> > Amol Pophale.
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
____________________________________________________________
> > Yahoo! Messenger - Communicate instantly..."Ping"
> > your friends today! Download Messenger Now
> > http://uk.messenger.yahoo.com/download/index.html
> >
> >
>
---------------------------------------------------------------------
> > 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
>
____________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: client-server Object Caching
Posted by Armin Waibel <ar...@apache.org>.
Hi Amol,
I read your previous posts carefully too, but I'm not sure that I can help.
Amol Pophale wrote:
> Hi All,
> Please read carefully and suggest me solution.
> I am working with one MNC s/w company.My application
> is web-based client-server application in which client
> and server are on different machines and uses same
> database. One imp thing one client might connect to
> more than one servers.Each server has one database
> which may be on server itself or on third machine.
> These servers stores some data in database.
> and also send a xml copy of same data on some port
> to client.web Clint get this data from server in the
> form of xml parses this xml and creates objects from
> that and stores in memory. If there are any changes in
> data server notify client so client can update its
> in-memory store.[client is not using database
> directly (jdbc)because firing query on Database every
> time is not feasible with current DB schema]But
> disadvantage of this is, if clients connect to
> multiple server [yes, there may be more than one
> servers]then performance of web-server on client
> decrease because it store data of all server in
> memory.
> Now we redesign the database schema and now client
> can connect to each server's database directly using
> OJB PersistanceBroker API and get data.
So you use PB-api only for read-only operations and persist objects via
the server - right?
And on the server you don't use OJB?
Can you describe a little more?
> IN Object
> cache implementation if there is some data in cache
> and
> same data get changed by server how clients knows this
> change and cache can be updated?
hmm, I don't recommend to use a distributed cache on client side this
will be overkill if you run more than a few clients. If you allow direct
access from the client to the DB I assume client/server/DB run in an
intranet. Do the client have to recognize changes in DB immediately or
is latency allowed? If not I recommend not cache data on client side or
to use the per broker cache (cache only data within a transaction or
till the PB instance was closed), otherwise you can use cached object
'timeout' property of the default object cache.
regards,
Armin
> This is my problem
>
> Thanks & Regards
> Amol Pophale.
>
>
>
>
>
>
>
>
> ____________________________________________________________
> Yahoo! Messenger - Communicate instantly..."Ping"
> your friends today! Download Messenger Now
> http://uk.messenger.yahoo.com/download/index.html
>
> ---------------------------------------------------------------------
> 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
client-server Object Caching
Posted by Amol Pophale <am...@yahoo.com>.
Hi All,
Please read carefully and suggest me solution.
I am working with one MNC s/w company.My application
is web-based client-server application in which client
and server are on different machines and uses same
database. One imp thing one client might connect to
more than one servers.Each server has one database
which may be on server itself or on third machine.
These servers stores some data in database.
and also send a xml copy of same data on some port
to client.web Clint get this data from server in the
form of xml parses this xml and creates objects from
that and stores in memory. If there are any changes in
data server notify client so client can update its
in-memory store.[client is not using database
directly (jdbc)because firing query on Database every
time is not feasible with current DB schema]But
disadvantage of this is, if clients connect to
multiple server [yes, there may be more than one
servers]then performance of web-server on client
decrease because it store data of all server in
memory.
Now we redesign the database schema and now client
can connect to each server's database directly using
OJB PersistanceBroker API and get data. IN Object
cache implementation if there is some data in cache
and
same data get changed by server how clients knows this
change and cache can be updated?
This is my problem
Thanks & Regards
Amol Pophale.
____________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Second try: (ODMG) Transaction.abort() vs. object rollback
Posted by Steve Clark <sc...@euler.cr.usgs.gov>.
Steve> So what are others doing about this situation? Does
Steve> everybody write their own snapshot/rollback code?
Armin> You can simply request the object again after abort.
Does Transaction.abort() remove all of its registered objects from the
cache? If so, then this solution will work fine for me.
-steve
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Second try: (ODMG) Transaction.abort() vs. object rollback
Posted by Armin Waibel <ar...@apache.org>.
Hi Steve,
Steve Clark wrote:
> Armin,
>
> The Javadocs are admittedly not very clear. From
> org.odmg.Transaction#abort():
>
> Abort and close the transaction. Calling abort abandons all
> persistent object modifications and releases the associated
> locks. Aborting a transaction does not restore the state of
> modified transient objects.
>
> The same text is in org.apache.ojb.odmg.TransactionImpl#abort().
> Although it's not clear what it means to "abandon all persistent
> object modifications",
> it sounds like rolling back, and the explicit
> mention of modifications to transient objects suggests that the
> behavior is different for modifications to persistent objects,
>
hmm, I don't know the ODMG specification in detail but I unwillingly
agree with you, seems it means rollback of all persistent object fields.
In that case I have to enable the "restore feature" again and have to
fix the problem with the modified collection-references (1:n) :-(
I will have a look at it - stay tuned
> So what are others doing about this situation? Does everybody write
> their own snapshot/rollback code?
>
You can simply request the object again after abort.
regards,
Armin
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Second try: (ODMG) Transaction.abort() vs. object rollback
Posted by Steve Clark <sc...@euler.cr.usgs.gov>.
Armin,
The Javadocs are admittedly not very clear. From
org.odmg.Transaction#abort():
Abort and close the transaction. Calling abort abandons all
persistent object modifications and releases the associated
locks. Aborting a transaction does not restore the state of
modified transient objects.
The same text is in org.apache.ojb.odmg.TransactionImpl#abort().
Although it's not clear what it means to "abandon all persistent
object modifications", it sounds like rolling back, and the explicit
mention of modifications to transient objects suggests that the
behavior is different for modifications to persistent objects,
So what are others doing about this situation? Does everybody write
their own snapshot/rollback code?
--
Steve Clark
Technology Applications Team
Natural Resources Research Center/USGS
sclark@support.tat.fws.gov
(970)226-9291
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Second try: (ODMG) Transaction.abort() vs. object rollback
Posted by Armin Waibel <ar...@apache.org>.
Hi Steve,
sorry for ignore your first post. Don't hesitate to post again and again
and ... ;-)
Steve Clark wrote:
>
> The way I read the Javadocs, if I make some changes to persistent
> objects which are locked to an ODMG Transaction, and then
> Transaction.commit() fails, e.g. due to a database constraint
> violation, then the objects in memory should be rolled back to their
> state prior to the Transaction. Is my understanding correct?
>
This was changed between rc5 and rc6 (see release notes, odmg restore).
The problem was that the restore function (rollback method in
ObjectEnvelope class, line 432 commented out) in odmg implementation
only can guarantee the restore of persistent fields of the main object
(non persistent fields are not restored). Modified refereneces, e.g.
removed objects of a 1:n reference collection can't be restored.
Thus I disabled this feature, instead all modified objects will be
removed from cache, so it is guaranteed that ODMG/OJB return a valid
object when called next.
Where in javadocs did you read that? This should be fixed.
regards,
Armin
> I am seeing the following behavior:
>
> tx1.begin();
> parent = fetchParent();
> tx1.commit();
> assert(parent.getChildren().size() == 1);
>
> tx2.begin();
> child = new Child();
> child.setSomeAttributeToInvalidValue();
> tx.lock(parent, WRITE);
> parent.addChild(child);
> try {
> tx2.commit();
> }
> catch TransactionAbortedException {
> assert(parent.getChildren().size() == 2);
> }
>
> My child object contains a value which violates a database
> constraint. On commit(), the Transaction, as expected, throws
> TransactionAbortedException. But the new Child object is still in
> the parent's collection of children, so future Transactions
> involving this parent will fail (including deletePersistent(),
> which attempts to insert the missing Child, not realizing that it
> will be immediately deleted).
>
> Is this the correct behavior?
> Should this be the expected behavior?
> If the answer to both questions is yes, then I think the Javadocs need
> some clarification.
>
> Finally, if this is the correct behavior, what are others doing to
> address this situation?
>
> I'm using CVS HEAD as of a week or so ago.
>
> thanks,
> --
> Steve Clark
> Technology Applications Team
> Natural Resources Research Center/USGS
> sclark@support.tat.fws.gov
> (970)226-9291
>
> ---------------------------------------------------------------------
> 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