From dev-return-19810-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Fri Dec 16 22:52:30 2011 Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9F56E9FB6 for ; Fri, 16 Dec 2011 22:52:30 +0000 (UTC) Received: (qmail 49752 invoked by uid 500); 16 Dec 2011 22:52:25 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 49664 invoked by uid 500); 16 Dec 2011 22:52:25 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 49594 invoked by uid 99); 16 Dec 2011 22:52:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Dec 2011 22:52:25 +0000 X-ASF-Spam-Status: No, hits=-2001.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Dec 2011 22:44:53 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id AAC8F117DDF for ; Fri, 16 Dec 2011 22:44:31 +0000 (UTC) Date: Fri, 16 Dec 2011 22:44:31 +0000 (UTC) From: "Heath Thomann (Updated) (JIRA)" To: dev@openjpa.apache.org Message-ID: <1732224029.21104.1324075471701.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <788257014.21011.1324074270572.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (OPENJPA-2095) Unhandled exception thrown from within an Externalizer method causes incorrect/incomplete SQL to be generated/executed. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-2095?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Heath Thomann updated OPENJPA-2095: ----------------------------------- Summary: Unhandled exception thrown from within an Externalizer method causes incorrect/incomplete SQL to be generated/executed. (was: Unhandled exception throw from within an Externalizer method causes incorrect/incomplete SQL to be generated/executed.) > Unhandled exception thrown from within an Externalizer method causes incorrect/incomplete SQL to be generated/executed. > ----------------------------------------------------------------------------------------------------------------------- > > Key: OPENJPA-2095 > URL: https://issues.apache.org/jira/browse/OPENJPA-2095 > Project: OpenJPA > Issue Type: Bug > Components: sql > Affects Versions: 1.2.3, 2.0.2, 2.1.2, 2.2.0 > Reporter: Heath Thomann > Assignee: Heath Thomann > Attachments: ExternalizerTest.zip > > > I've re-created an issue with Externalizers. That is, when the Externalizer method (i.e. the method listed in the @Externalizer) causes/throws an exception, OpenJPA generates, and executes, incorrect/incomplete SQL. To better explain, let me describe some test code snippets which are from the test I'll provide. First, take this entity: > @Entity > public class TestItem implements Serializable { > ..... > @org.apache.openjpa.persistence.Persistent > @org.apache.openjpa.persistence.Externalizer("check") > private TestExternal ext; > And take the following class TestExternal: > public static class TestExternal { > ..... > public String check() throws Exception { > throw new PersistenceException("test exception externalizer"); > With this code, lets look at the case where we persist a new TestItem, and the case where we update an existing one. When we create a new TestItem and persist it, OpenJPA generates and executes the following SQL: > INSERT INTO TESTITEM (data) VALUES (?) > However, this SQL should be generated: > INSERT INTO TESTITEM (iref, data, ext, name) VALUES (?, ?, ?, ?) > When we update an existing TestItem, OpenJPA generates, and executes, the following SQL: > UPDATE TESTITEM SET data = ? > However, this SQL should be generated: > UPDATE TESTITEM SET data = ? WHERE iref = ? > Because an unhandled exception is thrown by the Externalizer method, the transaction will be rolled back. However, if the SQL were to actually commit, every row in TestItem would be updated with the value in 'data'. Furthermore, in the case where there are hundreds/thousands of rows in the DB, the execution of the SQL may take a long time to complete and will maintain a lock on the TestItem table during the execution, possibly locking out other clients. > I've included a simple test, named ExternalizerTest.zip, which demonstrates the issue. > Thanks, > Heath -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira