openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Beer <david.m.b...@googlemail.com>
Subject Re: Bug in Delete from query ?
Date Mon, 14 Sep 2009 15:44:26 GMT
On Mon, 14 Sep 2009 09:19:43 +0200
Fabien Charlet <fabien.charlet@gmail.com> wrote:

> Hello !
> 
> I'm quite new to JPA and OpenJPA.
> I have developped a DAL using OpenJPA and HSQLDB for tests.
> 
> My problem is when I launch a "Delete from" query, HSQLDB complains
> about a malformed SQL syntax.
> 
> Here is my query :
> 
> final Query q = entityManager.get().createQuery("DELETE FROM Log");
> q.executeUpdate();
> 
> Where Log is an entity configured.
> But OpenJPA generates the query :
> 
> DELETE FROM LOG t0
> 
> And HsqlDB replies :
> 
> Caused by: org.hsqldb.HsqlException: unexpected token: T0
> 	at org.hsqldb.Error.error(Error.java:76)
> 	at org.hsqldb.ParserBase.unexpectedToken(ParserBase.java:749)
> 	at
> org.hsqldb.ParserCommand.compileStatement(ParserCommand.java:66) at
> org.hsqldb.Session.compileStatement(Session.java:808) at
> org.hsqldb.StatementManager.compile(StatementManager.java:418) at
> org.hsqldb.Session.execute(Session.java:882) at
> org.hsqldb.jdbc.JDBCPreparedStatement.<init>(JDBCPreparedStatement.java:3631)
> 
> I quickly looked at HsqlDB specs
> (http://hsqldb.org/web/hsqlDocsFrame.html), where I find that the
> query should be
> 
> DELETE FROM LOG
> 
> without the ending T0.
> 
> Is someone know this issue ?
> 
> I am using OpenJPA 1.2.1 and HsqlDB hsqldb-1.9.0-rc4
> 
> Thanks for help.
> 

Hi What it is it you are trying to delete an item from the table or the
table. As in general you have not specified what it has to delete.

The documentation actually says "DELETE FROM table [WHERE
Expression];" which will delete rows. You need to tell it what to
delete in the LOG table. 

-- 
Best Regards

David Beer

http://www.thebeerfamily.com

Mime
View raw message