Bruce,

I'm using WAS 5 and a UserTransaction.

As I told in my answer to Mickael, I used a different instance of Database for each database operation :(
I'm coding a facade over Castor in a J2EE context and I'm looking for some advice on how to do it correctly.
cf. my answer to Mickael:
http://www.mail-archive.com/[email protected]/msg11331.html

Cedrick

From: Bruce Snyder <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] problem while querying then deleting an object
Date: Fri, 20 Dec 2002 00:24:46 +0000 (GMT)

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

_________________________________________________________________
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