I hit the same thing myself some time back, it's a bit of an anomaly because in SQL you can use "delete from table" and if you don't specify a WHERE clause it will delete everything from the table.
Just my 2c Chris -----Original Message----- From: David Beer [mailto:[email protected]] Sent: Monday, 14 September 2009 11:44 PM To: [email protected] Subject: Re: Bug in Delete from query ? On Mon, 14 Sep 2009 09:19:43 +0200 Fabien Charlet <[email protected]> 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
