Fredy,

as pointed out by Bruce in his previous reply to you, you should use calls to 
Database.delete() to delete objects. With Castor, OQLQuery is used for 
*loading* objects *only*, not for updates and deletions.

To delete a UserJdo instance in your particular case, you'll have to re-oad the 
UserJdo instance and delete it subsequently, similar to ...

Database db = jdo.getDatabase();
db.begin();
UserJdo user = (UserJdo) db.load (UserJdo.class, new Integer (id));
db.delete (user);
db.commit();

Please note that above code fragment omits exception handling for the sake of brevity.

Regards
Werner

On Tue, 2 Mar 2004 22:02:13 +0100, [EMAIL PROTECTED] wrote:

>
>Hey all,
>i should delete a object witch was read in a "long transaction"
>I read the user with "getUser(..)" and transfer it to the client
>And if the client want's to delete it, i call "deleteUser(...)"
>
>The jdoHelper holds my database connection: jdoHelper.getDb()
>See my previous popsting for this.
>
>BaseVO is the base class of all my persistence objects !
>
>The Error:
>org.exolab.castor.jdo.oql.OQLSyntaxException: An incorrect token type
>was found near Delete (found IDENTIFIER, but expected KEYWORD_SELECT)
>
>But it's no select, its a delete ;-)))
>Is there something like "executeUpdate" ??
>How can i delete an object ?
>
>Thanks
>       Fredy
>
>
>public UserJdo getUser(String email) throws PersistException
>{
>       UserJdo userJdo = null;
> 
>       try
>       {                       
>               StringBuffer buf = new StringBuffer();
>               buf.append( "SELECT s FROM " );
>               buf.append( UserJdoImpl.class.getName() );
>               buf.append( " s WHERE strEmail=$1" );
>
>               OQLQuery query = jdoHelper.getDb().getOQLQuery(
>buf.toString() );
>                       
>               query.bind(email);
>                       
>               return (UserJdo)jdoHelper.executeBaseVO( query );
>                       
>       }
>       catch (PersistenceException  e)
>       {
>               throw new PersistException(e);
>       }
>}
>
>
>public BaseVO executeBaseVO(OQLQuery query) throws PersistenceException 
>{
>       db.begin();
>       QueryResults results = query.execute();
>       BaseVO baseVo = null;
>       if( results.size() > 0 )                        
>               baseVo = (BaseVO)results.next();
>       db.commit();
>       return baseVo;                  
>}
>
>
>public void deleteUser(String id) throws PersistException
>{
>       try
>       {
>               StringBuffer buf = new StringBuffer();
>               buf.append( "Delete FROM " );
>               buf.append( UserJdo.class.getName() );
>               buf.append( " s WHERE id=$1" );
>                       
>               OQLQuery query = jdoHelper.getDb().getOQLQuery(
>buf.toString() );
>                       
>               query.bind(id);
>                               
>               jdoHelper.executeBaseVO( query );
>               
>       }
>       catch (PersistenceException e1)
>       {
>               // TODO Auto-generated catch block
>               e1.printStackTrace();
>       }
>}
>
>
>-- 
>This message has been scanned for viruses and
>dangerous content by MailScanner, and is
>believed to be clean.
>MailScanner thanks transtec Computers for their support.
>
>----------------------------------------------------------- 
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
>        unsubscribe castor-dev
>





-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

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

Reply via email to