-->
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: Cannot read external changes in DB after session started
PostPosted: Fri Oct 14, 2011 9:23 pm 
Newbie

Joined: Thu Jul 28, 2011 8:17 pm
Posts: 3
hi,

Below is my observation:

1. Table A has 2 rows
2. Start a hibernate session
3. Remove one of the rows from table A using external operation (for example, manually remove it from some query browser)
4. Call findAll on the table A. It loads 2 entries, but I am expecting 1 as the db table A should only have 1 entry left after step 3

Is there any way to make step 4 loads from the DB of its current/latest status? I tried to call flush() on the hibernate session but it still shows 2 entries.

Or is it by definition that the hibernate session will ignore all the external changes to the DB once the session is started?

Many thanks in advance!


Top
 Profile  
 
 Post subject: Re: Cannot read external changes in DB after session started
PostPosted: Mon Oct 17, 2011 5:58 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
It is most likely a configuration issue for the "transaction isolation level" setting. Check your Hibernate configuration file for a setting named hibernate.connection.isolation. If it is not present, you should add it. The value is a number with 1=read uncommitted, 2=read committed, 4=repeatable read, 8=serializable

My guess is that you currently have 4 or 8, but what you really want is 2.


Top
 Profile  
 
 Post subject: Re: Cannot read external changes in DB after session started
PostPosted: Mon Oct 17, 2011 12:53 pm 
Newbie

Joined: Thu Jul 28, 2011 8:17 pm
Posts: 3
Thanks!!!

This totally solved my problem. We are using inno_db which is using REPEATABLE_READ.

I tried to set Isolation level earlier but Spring will not let me. However it works perfectly when I put it in the hibernate configuration file as suggested!

Again zillion thanks :) !


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.