-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate queries does not return newly inserted data
PostPosted: Wed Feb 18, 2009 2:04 pm 
Newbie

Joined: Wed Feb 18, 2009 12:56 pm
Posts: 5
First my apologies, for posting on the .NET forum. Sorry.

We have two applications. One of them have been developed using Hibernate (v3.3.1.GA) using Mysql (connector v:5.1.7). The second application is a legacy application. The legacy application inserts rows into mySQL. The hibernate application queries the data to display. But what we find is that the query does NOT pick up the newly updated/inserted data by the legacy application.

I researched for past couple of days and did the following

1. Disabled the secondary cache
2. Disabled the query cache
3. Cleared the session cache by calling session.clear() before executing the query.
4. Removed caching at the transaction scope/ session (calling sessionFactory.opensession(), clearing the cache, querying and closing the session()).

Inspite of all this the newly inserted data by the legacy app, is not picked up. What are we missing here?

If we somehow force the hibernate application to do an update/insert in any tables in the DB, all the changes by the legacy application magically appear (like they are supposed to).

Any help is greatly appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2009 8:33 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
It really sounds to be a caching problem. Post your code and configuration, so that we can help.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: Re: Hibernate queries does not return newly inserted data
PostPosted: Thu Mar 17, 2011 3:16 pm 
Newbie

Joined: Thu Mar 17, 2011 3:03 pm
Posts: 2
I have the same issue. I have legacy application that updates a mysql database and a web based hibernate application that renders the rows in the database. My hibernate application is not able to retrieve the rows inserted by the legacy application.

1) I am clearing the session cache by using session.clear() before executing the query
Code:
                        Query query=null;
         DAO= new ConnectionPoolDAO();
         Session session=DAO.getSession();
         System.out.println("Clearing session cache");
         session.clear();
         query = session.createQuery("from ConnectionPool");
         System.out.println("Querying ConnectionPools");


2) Turned off secondary and query cache
Code:
         <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
   <property name="hibernate.cache.use_second_level_cache">false</property>
   <property name="hibernate.cache.use_query_cache" >false</property>


3) The JSp page displaying the result does not cache any thing
Code:
<meta http-equiv="cache-control" content="no-cache">
   <meta http-equiv="expires" content="0">   


What am i missing out here.

However if i insert a row through the hibernate application subsequent queries return new rows inserted.

Any help will be greatly appreciated.


Top
 Profile  
 
 Post subject: Re: Hibernate queries does not return newly inserted data
PostPosted: Wed Mar 30, 2011 11:40 am 
Newbie

Joined: Thu Mar 17, 2011 3:03 pm
Posts: 2
Lowering isolation level seems to have resolved the problem.

This is the property I added to the hibernate properties file.

<property name="hibernate.connection.isolation">1</property>


Top
 Profile  
 
 Post subject: Re: Hibernate queries does not return newly inserted data
PostPosted: Tue Feb 04, 2014 10:21 am 
Newbie

Joined: Tue Feb 04, 2014 10:17 am
Posts: 1
Hi
I have tried the above things suggested
But still the data inserted in Mysql DB is not getting fetched
by the hibernate layer


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.