This one time, at band camp, Cdrick Laballery said:
CL>I'm meeting a problem with the following code:
CL>
CL><========== example ==========>
CL><assume ctx is a valid initial context>
CL>
CL>UserTransaction ut = (UserTransaction)
CL>ctx.lookup("java:comp/UserTransaction");
CL>// begin the transaction
CL>ut.begin();
CL>
CL>JDO jdo = (JDO) ctx.lookup("java:comp/jdo/myJdo");
CL>Database db = jdo.getDatabase();
CL>
CL>OQLQuery oql = db.getOQLQuery("select b from test.TotoBean b");
CL>
CL>QueryResults results = oql.execute();
CL>while (results.hasMore()) {
CL> totoBean = (TotoBean)results.next();
CL> log.debug(totoBean.toString());
CL>}
CL>// delete the last found bean
CL>totoBean.delete(); ==> raises an exception
CL>
CL>ut.commit();
CL>db.close();
CL><========== end of example ==========>
CL>
CL>totoBean.delete() causes a ObjectNotPersistentException:
CL>org.exolab.castor.jdo.ObjectNotPersistentException: The object of type
CL>test.TotoBean is not persistent -- it was not queried or created within this
CL>transaction
CL>The fact is that this object has obviously been created within the
CL>transaction...
CL>===> What's wrong with my code ?
CL>
CL>===> One more thing: if I begin the transaction *after* getting the
CL>database, the call to oql.execute() raises a
CL>TransactionNotInProgressException. Is it normal ?
CL>
CL>Thanks in advance for your help.
Cedrick,
What J2EE container are you using? What transaction type is being used?
Bruce
--
perl -e 'print unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev