Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
if i create sessionFactory multiple times, it's not a good solution as it will increase load on my application, so i want to keep it static and want to instantiate only once.
Originally posted by Paul Sturrock:
You don't need a new SessionFactory, just open a new Session. Sessions are cheap to create.
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Originally posted by Paul Sturrock:
When does your PHP app update the data? After you open the session?
The method you call will create a new connection to the database and read from it. So this will not return old data, it will return data from the current state of the database.
How are you ascertaining that your data is old?
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Originally posted by Paul Sturrock:
The SQL Client you are using, does it auto commit? Or do you need to manually commit data after you make a change?
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Originally posted by Paul Sturrock:
Well, if you are using Hibernate as you say you are then it is not Hibernate that is caching the data. SessionFacotry.openSession() gets a new connection from the pool. When you call get or load on that session the data is read from the database. I'd examine what your Flex app. is up to. Does it cache anythign itself?
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Originally posted by Paul Sturrock:
Do you use a query cache?
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Originally posted by g wildin:
Allow me to guess (disclaimer: I just took a hibernate class, but have no experience with it...). Maybe you are getting the detached object - that is why it is the old data. I think you can use if(session.contains(obj)) { session.evict(obj); } to remove it. Hope this helps.
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Any time an object passes through the Session instance, it's added to the Session�s cache. By passes through, we're referring to saving or retrieving the object to and from the database. To see whether an object is contained in the cache, call the Session.contains()method. Objects can be evicted from the cache by calling the Session.evict() method. Let's revisit the previous code, this time evicting the first Event instance:
Session session =factory.openSession();
Event firstEvent =(Event)session.load(Event.class,myEventId);
//...perform some operation on firstEvent
if (session.contains(firstEvent)){
session.evict(firstEvent);
}
Event secondEvent =new Event();
secondEvent.setId(myEventId);
session.save(secondEvent);
The code first opens the Session instance and loads an Event instance with a given ID. Next, it determines whether the object is contained in the Session cache and evicts the object if necessary. The code then creates a second Event instance with the same ID and successfully saves the second Event instance.
If you simply want to clear all the objects from the Session cache, you can call the aptly named Session.clear()method.
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
- Cache provider: org.hibernate.cache.EhCacheProvider
- Second-level cache: enabled
Originally posted by Jaikiran Pai:
Somewhere in your xml's i guess you have configured hibernate.cache.provider_class to use EhCache. I believe that's the reason why the second level cache is enabled. Remove that property from the xml and see if its works.
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
I think hibernate keeps reference of both the object in memory.......
So in this case how to delete older reference Of object in memory.???
Originally posted by Paul Sturrock:
Please don't wake up old topics.
Sunil Kumar Gupta had two applications accessing the database, the Java one doing so through a web service backed by Hibernate. And he was using the second level cache. Is your application's architectrue the same (or simmilar) and have you tried all the suggestions listed above?
Originally posted by Paul Sturrock:
Post the code where you update your data.
Originally posted by Satish Kandagadla:
Have you tried checking the database after updating it with the first client? Is the data updated in the database?
[ November 14, 2008: Message edited by: Satish Kandagadla ]
Originally posted by Ngoc Tiep Vu:
Yes, i have check the data in database server. After updating with the first client, data in database is updated, but the second client can read only the old data.
Originally posted by Satish Kandagadla:
Did you use the same HibernateUtil class as the one posted in the Hibernate site or you have created one of your own? can you paste the code for HibernateUtil class?
Danger, 10,000 volts, very electic .... tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
|