openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Bauer <techhu...@gmail.com>
Subject Re: entity is not available in memory
Date Fri, 18 May 2012 20:08:26 GMT
Prabhu,

Since you didn't mention the EJB 3.0 feature pack for WAS 6.1, I'm
assuming you are using OpenJPA via JSE bootstrapping with resource
local transactions.  Ignoring the possibility of issues related to
using a thread local for now, one thing that jumped out at me is that
your JPQL has quotes around the value in the predicate.  That
indicates the value is a string.  If C.id is numeric there is a very
good chance the comparison will fail.  Just something to check..
Also, you should consider using em.find() for single result, primary
key lookup.  In general, it is more straight forward and will perform
better than a JPQL query.

hth,
-Jeremy

PS. If you are using the EJB 3.0 feature pack, you could use container
managed JPA.  Container managed JPA allows automatic propagation of
the persistence context within a transaction (ie. no need to store the
em in a thread local).

On Wed, May 16, 2012 at 2:58 PM, pbt123 <prabhash@in.ibm.com> wrote:
> Hello,
>
> I am new in 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) then B, C, E, F, G entity.
>
> While again setting values in Entity C, it needs previous entered data 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 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-tp7562566.html
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Mime
View raw message