|
Hi,
I have the function to query a table ( in Oracle ).
The strange problem is that I never modify any data, but when
1.
I db.commit(); it reports that:
org.exolab.castor.jdo.ObjectModifiedException:
Transaction aborted: Object of type com.macrotech.PI_OE.model.OrderJDO with
identity 1 has been modified by a concurrent transaction
at
org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:503)
2.
If I db.close(); directly, without db.commit(); It
reports that:
org.exolab.castor.jdo.PersistenceException:
jdo.dbClosedTxRolledback
at
org.exolab.castor.jdo.engine.DatabaseImpl.close(DatabaseImpl.java:248)
3.
If I use db.rollback(); instead
of db.commit(); it is ok.
I was confused, what's the problem?
Annie
public ArrayList getOrders(String
sCondition)
throws Exception{
Database
db;
OrderJDO order; OQLQuery orderOql; QueryResults results;
ArrayList res = new ArrayList();
db =
_jdo.getDatabase();
db.begin();
String oql = "SELECT o FROM model.OrderJDO o"; if (sCondition != null && sCondition.length() != 0) oql += " where " + sCondition; orderOql = db.getOQLQuery( oql ); results = orderOql.execute(); while ( results.hasMore() ) { results.next(); // order = (OrderJDO) results.next(); // even if I comment these two lines, the result is same // res.add(order); }
db.commit();
// db.rollback(); // if I use rollback(), it will be ok. db.close(); return
res;
} |
