Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2E19010444 for ; Mon, 21 Oct 2013 15:18:39 +0000 (UTC) Received: (qmail 9581 invoked by uid 500); 21 Oct 2013 15:18:38 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 9367 invoked by uid 500); 21 Oct 2013 15:18:31 -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 9345 invoked by uid 99); 21 Oct 2013 15:18:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Oct 2013 15:18:29 +0000 X-ASF-Spam-Status: No, hits=2.3 required=5.0 tests=SPF_SOFTFAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: softfail (athena.apache.org: transitioning domain of mrgiba@ig.com.br does not designate 216.139.236.26 as permitted sender) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Oct 2013 15:18:25 +0000 Received: from jim.nabble.com ([192.168.236.80]) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VYHF6-00085t-7P for users@openjpa.apache.org; Mon, 21 Oct 2013 08:18:04 -0700 Date: Mon, 21 Oct 2013 08:18:04 -0700 (PDT) From: "givanildo.alves" To: users@openjpa.apache.org Message-ID: <1382368684196-7585290.post@n2.nabble.com> Subject: Intermittent EntityNotFoundException for lazy loading of ID field MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi, In my current model, a ConcreteRecord might be associated to N AliasRecord instances. The relationship is bidirectional: ManyToOne specified in AliasRecord class and OneToMany specified in ConcreteRecord. I am testing a concurrent scenario where each thread creates a new AliasRecord and a new ConcreteRecord instances: 1. AliasRecord newAlias = 2. entityManager.persist(newAlias); 3. ConcreteRecord newConcreteRecord = 4. 5. entityManager.persist(newResource); 6. newAlias.updateTimeStamp(); 7. newAlias = entityManager.merge(newAlias); 8. However, now and then I get the an error when getting the ID value for the ConcreteRecord instance: org.apache.openjpa.persistence.EntityNotFoundException: The instance of type "class com.test.testapp.model.ConcreteRecord" with oid "null" no longer exists in the data store. This may mean that you deleted the instance in a separate transaction, but this context still has a cached version. FailedObject: com.test.testapp.model.ConcreteRecord@268fae22 at org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:3119) at org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:3195) at org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1658) at org.apache.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1591) at com.test.testapp.model.ConcreteRecord.pcGetrecordId(ConcreteRecord.java) at com.test.testapp.model.ConcreteRecord.getRecordId(ConcreteRecord.java:167) at com.test.testapp.model.AliasRecord.toString(AliasRecord.java:479) at com.test.testappaspects.log.Logging.getArguments(Logging.aj:363) at com.test.testappaspects.log.Logging.ajc$before$com_test_testapp_aspects_log_Logging$3$a001ed84(Logging.aj:253) at com.test.testapp.persistence.ReconciliationManager.doReconciliationForNewAlias(ReconciliationManager.java:180) at com.test.testapp.persistence.AliasManager.doCreateAlias(AliasManager.java:345) at com.test.testapp.persistence.AliasManager.createAlias(AliasManager.java:105) at com.test.testapp.web.AliasService.createAliasRecord_aroundBody2(AliasService.java:334) at com.test.testapp.web.AliasService.createAliasRecord_aroundBody3$advice(AliasService.java:62) at com.test.testapp.web.AliasService.createAliasRecord(AliasService.java:1) at com.test.testapp.web.AliasService.createAliasRecord_aroundBody0(AliasService.java:227) at com.test.testapp.web.AliasService.createAliasRecord_aroundBody1$advice(AliasService.java:93) at com.test.testapp.web.AliasService.createAliasRecord(AliasService.java:201) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:602) at org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:63) According to the logs, it seems OpenJPA attempted to load from the database a record with null ID [10/15/13 17:31:09:234 BRT] 00000054 OpenJPA 3 openjpa.jdbc.SQLDiag: Trace: load: class com.test.testapp.model.ConcreteRecord oid: null [10/15/13 17:31:09:234 BRT] 00000054 OpenJPA 3 openjpa.jdbc.SQL: Trace: executing prepstmnt -1427080773 SELECT t0.RECORD_ID FROM CONCRETE_RECORD t0 WHERE t0.RECORD_ID IS NULL That is odd, knowing that the ConcreteRecord instance had its ID value assigned prior to the EntityManager.persist(...) call and each thread operates with different records and does no deletion My environment: - WebSphere 8.5.0.2 - OpenJPA 2.2.1.1 snapshot version bundled with WebSphere - IBM JDK 7 build pwa6470sr1ifix-20120419_02(SR1+IV19490+IV19661) The problem also happens with Apache OpenJPA 2.2.2 release and the latest OpenJPA 2.3.0 nightly build. For JDK 7, I could also reproduce the problem with IBM JDK SR4_FP2 release. The curious part is that the problem does not happen with IBM JDK 6. Has anyone stumble upon a similar issue ? Thanks -- View this message in context: http://openjpa.208410.n2.nabble.com/Intermittent-EntityNotFoundException-for-lazy-loading-of-ID-field-tp7585290.html Sent from the OpenJPA Users mailing list archive at Nabble.com.