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 4149B9567 for ; Wed, 16 May 2012 21:32:30 +0000 (UTC) Received: (qmail 12509 invoked by uid 500); 16 May 2012 21:32:30 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 12448 invoked by uid 500); 16 May 2012 21:32:30 -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 12436 invoked by uid 99); 16 May 2012 21:32:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 May 2012 21:32:30 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kwsutter@gmail.com designates 209.85.217.174 as permitted sender) Received: from [209.85.217.174] (HELO mail-lb0-f174.google.com) (209.85.217.174) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 May 2012 21:32:25 +0000 Received: by lbbgm6 with SMTP id gm6so1288625lbb.33 for ; Wed, 16 May 2012 14:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=s5LEjtiPT4k/bH8o6Jktx9+4yJmnoDY+JZQSX8xiOA0=; b=0+ojwtZnrPyW9/yjkdDfGIEbFpxFZYUcnfI6UeGkZAg29PtkCp0RJXtngEn+NCFUgX dX0pfiwAhqOWffbdvDudM009qWeVm14XRT5qEYXu1F10/MLyWLZCcMOcTdhL6gBCZQc0 xJpKIWLjhA+aa3fVy3OYmnpaLo0vHfH9xSftH+rBuPIZlekx4qOwnvRBB+gg8WAjIk0W GCjgjcuQy2ffmyTIKKotseIwz0jZ9GT3Vtpu+Z/GO0lggGewKjmgmgdZfAYYbfuj8TVk 6DwpliPiJAMB+lflxZ48pI3845Al8PnfW5+FrLvKnSc+OzJXzpgqIHooJ7/48Q7py5lA 6NGg== Received: by 10.112.41.2 with SMTP id b2mr1688448lbl.58.1337203923526; Wed, 16 May 2012 14:32:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.22.10 with HTTP; Wed, 16 May 2012 14:31:43 -0700 (PDT) In-Reply-To: <1337200847097-7562678.post@n2.nabble.com> References: <1337200847097-7562678.post@n2.nabble.com> From: Kevin Sutter Date: Wed, 16 May 2012 16:31:43 -0500 Message-ID: Subject: Re: entity is not available in memory-repost To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=e0cb4efe2a28daa5e904c02e0c41 X-Virus-Checked: Checked by ClamAV on apache.org --e0cb4efe2a28daa5e904c02e0c41 Content-Type: text/plain; charset=ISO-8859-1 Hi Prabhu, First question: Are you sure that your database has the 5 previous records with z.id ='10203'? That is, have you committed your previous transactions that would ultimately flush your changes to the database? Since you are using OpenJPA 2.x with WAS v6.1, you must be using application-managed persistence. (In order to use container-managed persistence with OpenJPA 2.x, you would need the OSGi/JPA 2.0 Feature Pack for WAS v7.) With application-managed persistence, the lifecycle of the EMF and EM is up to your application. You may be able to tie into the Transaction demarcation, but that requires a configuration property [1]. Bottom line is that I think you need to review your application and how it interacts with transactions (JTA or local) and determine whether your changes are even getting to the database before you attempt to query for them. BTW, there are ways to do in-memory queries of your current persistent context, but let's keep this simple until we understand your scenario better. Good luck, Kevin [1] http://www.ibm.com/developerworks/websphere/techjournal/0612_barcia/0612_barcia.html On Wed, May 16, 2012 at 3:40 PM, pbt123 wrote: > Hello, > > I am new on OpenJPA....not sure if it has very common solution. > > OpenJpa version: 2.1.1 > Running on WAS6.1.37 > > I have 7 entities in a transaction, first set values in Entity A (fields > id=10203, name, pname..... etc ...one record) then B (2 record), C(5 > records), E(3 records), F (2 records), G (2 records) entities. > > While again setting values in Entity C, it needs previous entered > data(previous 5 records) from > C using custom query. > > Query query = em.createQuery( "SELECT z FROM C z where z.id='10203'"); > > I am using threadLocal to set EntityManager (I have already checked, it is > trying to get data from the same entityManager which has set value in > entity > A ). There are lot of business logic involved in between entity A till G. > > The problem is, I am not able to get previous data(5 records) from entity C > using the > above SQL. it always return zero result for id=10203. > > Can anyone please help? > > Many Thanks. > Prabhu > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/entity-is-not-available-in-memory-repost-tp7562678.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > --e0cb4efe2a28daa5e904c02e0c41--