Obviously if you have all caching turned off, then you could possibly do some deletes yourself using direct sql calls, but I would only go that route if I had a really clear need for it, not just based on the assumption that it will be slow... if you've got caching turned on, then the call to materialize the object may not be nearly as expensive as you anticipate since the objects may already be in the cache.
-mm -----Original Message----- From: Bruce Snyder [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 10, 2002 3:23 PM To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Remove Objects without loading them? This one time, at band camp, Havemeister, Thomas said: HT>This is perhaps a simple question: How can I remove Objects by ID without loading them before using and the "remove()" command? HT> HT>Here is a code snippet: HT> HT> public void removeRequirement(Vector pVector) HT> throws PersistenceException HT> { HT> if (isActive() == false) HT> { HT> begin(); HT> } HT> HT> int lId=0; HT> for (Enumeration enum=pVector.elements(); enum.hasMoreElements(); ) HT> { HT> lId = ((Integer) enum.nextElement()).intValue(); HT> requQuery.bind(lId); HT> remove( (this.requQuery.execute()).next()); HT> } HT> commit(); HT> } HT> HT>this will work, but is of course quite slow, because the castor is loading each object, before removing it. HT> HT>When processing somethin like this: HT> HT> .... HT> Requirement lReq = new Requirement(); HT> lReq.setId(xx); HT> remove (lReq); HT> .... HT> HT>an Exception will be thrown. What is the best way for removing objects using castor? Thomas, Castor currently requires that objects be loaded in order to be removed. This is so that the cache can be properly updated upon object removal. 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 ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
