Hi,
I'm sure this is a common requirement, how does one have multiple objects
open for editing in the same process and be able to choose which should be
committed?
I am writing a application which can be used to open and edit multiple
Objects concurrently, using ojb's odmg api as a persistence layer. I would
like to give the user the option to 'Save changes' or 'Drop changes' which
I'm sure is a common requirement. My problem arises with how I should use
ojb/odmg transactions. My initial idea was that I should associate a
transaction with each object being concurrently edited, for example:
Transaction trx1 = odmg.newTransaction();
Transaction trx2 = odmg.newTransaction();
trx1.begin();
trx2.begin();
trx1.lock(obj1, tx.WRITE);
trx2.lock(obj2, tx.WRITE);
//...code to allow the user edit obj1 and obj2
//...code to allow user to persist either obj1 or obj2, or both or
neither.
But if I commit one transaction it is not possible to commit the other
without causing an error: "Calling method needed transaction, but no
transaction found for current thread :-(". It seems that it is possible to
persist both objects using checkpoint rather than commit:
trx1.checkpoint();
trx2.checkpoint();
But there is still a problem if the user chooses to save one of the objects
but not the other. It is desirable to release the lock on the object which
is not being saved:
trx1.abort();
[note that: trx1.lock(obj1, tx.READ) does not downgrade the lock here, it
says in the API documentation that locks can only be increased. Which is why
I use trx1.abort() to remove the lock]
However a subsequent call:
trx2.commit();
OR
trx2.checkpoint();
Fails with the same error above.
Is concurrent editing of different objects, in which you can commit (or
otherwise persist) some objects but not others, supported with ojb/odmg? I
would like to use ojb/odmg to lock and commit my objects so that my
application has the ability to warn the user when they request the lock to
edit a object and that object is already locked by another process running
my application (i.e. open for editing by another user).
Can anyone recommend a way to achieve this?
Any help or suggestions would be greatly appreciated.
Adam
P.S.
I assume my problems above are all because odmg Transactions are using a
shared org.apache.ojb.broker.PersistenceBroker... But I'm not sure if I'm
right or how to get arround the problem.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]