I'm testing the ODMG layer with this example:
/**
* Update the Traente instance on the database
*/
public void update() {
Database db = odmg.newDatabase(); // the current DB
Transaction tx = null;
//open database
try {
db.open("default", Database.OPEN_READ_WRITE);
} catch (ODMGException ex) {
ex.printStackTrace();
}
tx = odmg.newTransaction();
String oqlQuery = "select edit from " +
traente.className +
" where id = " + traente.getId();
try {
tx = odmg.newTransaction();
tx.begin();
OQLQuery query = odmg.newOQLQuery();
query.create(oqlQuery);
DList result = (DList) query.execute();
Traente toBeEdited = (Traente) result.get(0);
tx.lock(toBeEdited, Transaction.UPGRADE);
toBeEdited = traente;
tx.commit();
} catch (Throwable t) {
// rollback in case of errors
tx.abort();
t.printStackTrace();
}finally {
try {
db.close();
System.out.println("DB closed!!!!");
} catch (ODMGException ex) {
ex.printStackTrace();
}
}
}
where 'traente' is a class attribute that rapresents the updated object that
i would like to persist.
After the method invocation .... the database still contains the old object,
while retrieving again the reference 'toBeEdited' it seems to be updated.
What do I miss? I'm using a test class on JBuilder, without any particular
deployement enviroment.
Thanks in advance
Massimiliano Farnea
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]