-->
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.  [ 1 post ] 
Author Message
 Post subject: Delayed persistence?
PostPosted: Sat Jul 21, 2007 11:41 pm 
Newbie

Joined: Tue Jan 16, 2007 2:56 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Mapping documents: yes

Code between sessionFactory.openSession() and session.close():
Used both Entity Manager and Hibernate Session

Full stack trace of any exception that occurs:

Name and version of the database you are using:
MySQL

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


I used EntityManager to persist the objects and then used Session from SessionFactory to query the saved data. The problem (I am not sure if this is a problem or intended behavior) is that when I query right after the EM persist call, I don't get the data, yet the data shows up in MySQL using Query Browser. After executing the same query using the session, I got the data randomly (when I got it, it is correct). If I restart Tomcat, then I can see the persisted data consistently. So I am wondering if there is some kind of delay (caching) between EM and Session? The part I don't understand is that why I would see the data (hit and miss) when I make the same call? Is certain function I didn't set up properly that caused this problem?

Edit: BTW, I tried persisting using the session instead of EM and the result is the same (has the delay).

The criteria based query (which hit and miss randomly) looks like this:
List<Object[]> results = session.createCriteria(Rating.class)
.createAlias("topic", "t")
.add(Restrictions.eq("campaign.id", campaignId))
.add(Restrictions.eq("target.id", targetId))
.addOrder(Order.desc("createTime"))
.addOrder(Order.desc("userId"))
.addOrder(Order.desc("t.index"))
.list();

Any explanation is welcome. Thanks!


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

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.