-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: JPA/Hibernate Query Returns Stale Results
PostPosted: Wed Jun 17, 2009 9:53 pm 
Newbie

Joined: Tue Jul 22, 2008 5:11 pm
Posts: 16
I am using an EXTENDED Persistent Context because it will allow me to Lazily Load a one-many relationship on an object and it also won't require a SELECT before I "merge" an object with the persistent context.

I have an DummyObject with:

1. A "Last Updated" Date Field
2. A One-Many Relationship

This Object is being updated every 5 seconds in one JVM through a
Code:
em.merge(DummyObject)
call.

In another JVM, I query for the DummyObject doing a call like the following

Code:
em.createQuery("from DummyObject").getResultList();

I am also doing this Query every 5 seconds.

The problem is, is that the Objects resulted from the Query all have a Timestamp of the very first Query after successive calls, even though Hibernate is generating the correct SQL statement (when I have statement logging on), and the Database is getting the updates correctly (I have verified).

I have also tried all sorts of optimistic locking with @Version to no avail. (See comments)

Another thing is that this does work correctly when:

1. I change the PersistentContextType to TRANSACTIONAL (something that will not allow me to lazily load the ONE-MANY relationship)
2. I do an EntityManager.clear() call before I do the Query above (Something that will also not allow me to lazily load the ONE-MANY relationship.

Why does my Query return stale data? I have no Second Level Caching or Query Caching enabled.

Am I doing something wrong? Maybe I don't understand "EXTENDED" correctly.


Top
 Profile  
 
 Post subject: Re: JPA/Hibernate Query Returns Stale Results
PostPosted: Thu Jun 18, 2009 5:37 pm 
Newbie

Joined: Tue Jul 22, 2008 5:11 pm
Posts: 16
Does anyone have any ideas? This is really bugging me.


Top
 Profile  
 
 Post subject: Re: JPA/Hibernate Query Returns Stale Results
PostPosted: Sat Jun 20, 2009 3:55 am 
Newbie

Joined: Sat Jun 20, 2009 3:48 am
Posts: 2
Where can I find more information on Extended persistence context??

Thanks,
Ishtiak
http://www.interview-questions-tips-forum.net


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.