Hi,

I'm just starting using OJB and i'm facing a problem :

I have a persistent class that has an attribute 'name' and i update it
through a method setName :

Public void setName(String _name) {
    // tests...
    this.name = _name;
    try {
        broker.beginTransaction();
        broker.store(this);
        broker.commitTransaction();
    }
    catch (PersistenceBrokerException e) {
        broker.abortTransaction();
        ...
    }
}

Nothing exotic, you can see !

If a problem occurs while updating the database, the transaction is rolled
back but the object in memory (it is referenced somewhere in my app so it
stays in memory) is modified and so it does not reflect anymore the database
state.

The only solution i found  is to save the original value of the name
attribute at the beginning of the function and reset it in the catch block.
But for more complex changes it start to be a bit tricky !

Is there any other (better) solution ? Am I doing all wrong ?

Any advice is welcome ! :)

Best regards,

Damien Coueron


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

Reply via email to