Hi Andrew,

Andrew wrote:
> I need work with transactions like this:
> // ======================
> tx1.begin()
> tx2.begin()
> load object a in tx1

do you only load an object a from the DB, or do want to store it?
Believe that you want to store a too.

> create object b in tx2
> tx1.commit()
>
> if( OK )
>   tx2.commit()
> else
>   tx2.abort()
> // ======================
> And so on.


'Nested Transactions' are not part of the ODMG api, thus we currently
not support it. Maybe in futher version (when we implemented the OTM
layer)
we support this feature. Feel free to request nested transactions as new
feature.

Back to your situation. Currently you could use 'Checkpoints' to solve
your problem
if all your objetcs match the SAME database. API says:Checkpoint -
Commit the transaction,
but reopen the transaction, retaining all locks.
Say you want to store object A, if this was possible you want to store a
B object,
if this was possible store a C object, ... If storing of A fails, do
something, if storing
of B fails do something else, .... But keep in
mind if storing of obj C fails it's not possible to rollback the whole
process (rollback
storing of B and A) - unless you implement your own rollback process.

tx.begin();
try
{
    tx.begin();
    tx.lock(objA, Transaction.WRITE);
    tx.checkpoint();
}
catch(Exception e)
{// do something}
try
{
    tx.lock(objB, Transaction.WRITE);
    tx.checkpoint();
}
catch(Exception e)
{// do something else}
 ...
 tx.commit();

If your objetcs do not match the same database, you need support
for distributed transactions. Currently OJB does not support distributed
transactions. But when using OJB within a J2EE conform environment
(like jboss, OJB within session beans) it's possible.


HTH
regards,
Armin

----- Original Message -----
From: "Andrey Chernyh" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 15, 2002 7:19 AM
Subject: Several transactions opened at the same time in one thread...


>
> Hi!
>
> >2. ODMG: just call OJB.newTransaction();
> It will not help me, because it will overwrite my prevoius transaction
> associated with current thread.
>
> I need work with transactions like this:
> file://======================
> tx1.begin()
> tx2.begin()
> load object a in tx1
> create object b in tx2
> tx1.commit()
>
> if( OK )
>   tx2.commit()
> else
>   tx2.abort()
> file://======================
> And so on.
>
> Can you tell something about it?
>
>
>
> Andrey Chernyh wrote:
> > Hello!
> > I need to have at least two transactions opened when working with
OJB.
> > But currently I can't do it.
> > Please tell me if it is possible and how?
> >
>
>
> Best regards,
> Andrey Chernyh<[EMAIL PROTECTED]>
> Plesk Inc.
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to