Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 79972 invoked from network); 14 Sep 2009 16:38:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Sep 2009 16:38:34 -0000 Received: (qmail 26208 invoked by uid 500); 14 Sep 2009 16:38:33 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 26177 invoked by uid 500); 14 Sep 2009 16:38:33 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 26167 invoked by uid 99); 14 Sep 2009 16:38:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Sep 2009 16:38:33 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.210.187] (HELO mail-yx0-f187.google.com) (209.85.210.187) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Sep 2009 16:38:22 +0000 Received: by yxe17 with SMTP id 17so4009082yxe.9 for ; Mon, 14 Sep 2009 09:38:00 -0700 (PDT) Received: by 10.100.18.15 with SMTP id 15mr6407396anr.48.1252946280293; Mon, 14 Sep 2009 09:38:00 -0700 (PDT) Received: from brevsnb004 ([118.97.33.171]) by mx.google.com with ESMTPS id b14sm31287ana.2.2009.09.14.09.37.56 (version=SSLv3 cipher=RC4-MD5); Mon, 14 Sep 2009 09:37:59 -0700 (PDT) Reply-To: From: "C N Davies" To: References: <92ad09f30909140019g7c6de334u96f0494433a8b6ad@mail.gmail.com> <20090914164426.67645172@googlemail.com> In-Reply-To: <20090914164426.67645172@googlemail.com> Subject: RE: Bug in Delete from query ? Date: Tue, 15 Sep 2009 00:37:47 +0800 Organization: C N Davies Pty Ltd Message-ID: <004501ca3559$b4b2f930$1e18eb90$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Aco1UlTQY1e6A+/HQlii4+HlziKBgwABx1EQ Content-Language: en-au X-Virus-Checked: Checked by ClamAV on apache.org 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:david.m.beer@googlemail.com] Sent: Monday, 14 September 2009 11:44 PM To: users@openjpa.apache.org Subject: Re: Bug in Delete from query ? On Mon, 14 Sep 2009 09:19:43 +0200 Fabien Charlet 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.(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