Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 19170 invoked from network); 18 Sep 2009 15:18:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Sep 2009 15:18:05 -0000 Received: (qmail 92901 invoked by uid 500); 18 Sep 2009 15:18:04 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 92848 invoked by uid 500); 18 Sep 2009 15:18:04 -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 92838 invoked by uid 99); 18 Sep 2009 15:18:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Sep 2009 15:18:04 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists+1214986160035-208411@n2.nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Sep 2009 15:17:54 +0000 Received: from tervel.nabble.com ([192.168.236.150]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1MofDK-00022q-9o for users@openjpa.apache.org; Fri, 18 Sep 2009 08:17:34 -0700 Date: Fri, 18 Sep 2009 08:17:34 -0700 (PDT) From: ecerulm To: users@openjpa.apache.org Message-ID: <1253287054302-3670456.post@n2.nabble.com> Subject: OpenJPA generates extra UPDATEs MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: ruben.laguna@gmail.com X-Virus-Checked: Checked by ClamAV on apache.org Hi, I have the following snippet of code EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistencexmltest1PU"); EntityManager em = emf.createEntityManager(); for (int i = 0; i < 10; i++) { em.getTransaction().begin(); MyEntity n =new MyEntity(); n.setValue(i); em.persist(n); em.getTransaction().commit(); //em.clear(); //This shouldn't be needed, right? } And OpenJPA 1.2.0 (with HSQLDB) is generating INSERT INTO MYTABLE (ID, VALUE, CREATED) VALUES (?, ?, ?) [params=(int) 1, (int) 0, (null) null] INSERT INTO MYTABLE (ID, VALUE, CREATED) VALUES (?, ?, ?) [params=(int) 2, (int) 1, (null) null] UPDATE MYTABLE SET CREATED = ? WHERE ID = ? [params=(null) null, (int) 1] INSERT INTO MYTABLE (ID, VALUE, CREATED) VALUES (?, ?, ?) [params=(int) 3, (int) 2, (null) null] UPDATE MYTABLE SET CREATED = ? WHERE ID = ? [params=(null) null, (int) 2] UPDATE MYTABLE SET CREATED = ? WHERE ID = ? [params=(null) null, (int) 1] The MyEntity entity IS enhanced so I guess that https://issues.apache.org/jira/browse/OPENJPA-546 doesn't apply. If I call EntityManager.clear() after the commit then the issue is fixed. But is this the expected behaviour? OpenJPA is generating SQL updates for unchanged entities within the transaction, that is not what I was expecting. For me, this started when I added a @Temporal(TemporalType.TIMESTAMP) field to the entity (MyEntity). With a "simpler" entity I get only INSERTs (no UPDATEs). http://rubenlaguna.com/wp/2009/09/18/openjpa-generated-sql-contains-extra-updates/ -- View this message in context: http://n2.nabble.com/OpenJPA-generates-extra-UPDATEs-tp3670456p3670456.html Sent from the OpenJPA Users mailing list archive at Nabble.com.