Hi all,

I'm meeting a problem with the following code:

<========== example ==========>
<assume ctx is a valid initial context>

UserTransaction ut = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
// begin the transaction
ut.begin();

JDO jdo = (JDO) ctx.lookup("java:comp/jdo/myJdo");
Database db = jdo.getDatabase();

OQLQuery oql = db.getOQLQuery("select b from test.TotoBean b");

QueryResults results = oql.execute();
while (results.hasMore()) {
totoBean = (TotoBean)results.next();
log.debug(totoBean.toString());
}
// delete the last found bean
totoBean.delete(); ==> raises an exception

ut.commit();
db.close();
<========== end of example ==========>

totoBean.delete() causes a ObjectNotPersistentException:
org.exolab.castor.jdo.ObjectNotPersistentException: The object of type test.TotoBean is not persistent -- it was not queried or created within this transaction
The fact is that this object has obviously been created within the transaction...
===> What's wrong with my code ?

===> One more thing: if I begin the transaction *after* getting the database, the call to oql.execute() raises a TransactionNotInProgressException. Is it normal ?

Thanks in advance for your help.

Cedrick

_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous ! http://search.msn.fr/worldwide.asp

----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev

Reply via email to