• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cache problem: After 2/3 updates, data fetched is not the latest

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everybody,

The problem I m facing is probably due to the hibernate cache. The problem exists in the form which queries 2 tables to fetch the data. The update opration is performed in the same form. After update, the form needs to show the updated data. But, after 2 or 3 updates, the data fetched doesnot contain the currently updated values, rather contains the previously updated values. The updated values are not shown even when the page is refreshed manually through the browser. Although the DB tables get updated. Its only when the data is re-queried, that the page reappears to show the updated results.

Additional Information that may help:
1) Hibernate version 3.0 being used with JBOSS server
2) the 2 tables have 1:n mapping
3) Update operation is being implemented as follows:



4) Second Level Cache is not enabled
5) Query Cache is enabled

Hoping to find a quick solution.......
------------------
Devesh Chanchlani.
------------------
[ October 17, 2007: Message edited by: Mark Spritzler ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's with the copying and the loading of data from the database? Why do you need to do that?

I am then assuming that you are copying and the object instance has the values, but then you return a different object with the old data back to the client. It just seems convoluted to be able to even give you a good reason why you are seeing what you are seeing.

Good Luck

Mark
 
Devesh Chanchlani
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

If there would be a problem with the data object I m returning, then I would have never got the updated results. for the first few updates, generally 2 or 3, I get the appropriate values, but after this if I make any further updates, I do not get the proper updated result back on the front-end.

Please suggest any work-around...

-----------------
Devesh Chanchlani
-----------------

"The journey of a thousand miles begins beneath one's feet."
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, then don't answer my questions.

I would simply remote debug and put stop points on each call to saveOrUpdate in your if and else statements, since I see three of them, I bet there is a chance that one or another are or aren't being called when it updates and a different result when it doesn't update.

My guess would be that when it doesn't return the updated version to the UI is because it calls this version session.saveOrUpdate(copyTransientInstance); and you are returning the transientInstance to the client, which hasn't been updated.

I usually ask questions for a reason.

Mark
 
Devesh Chanchlani
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the delay in reply, as I was not working on this issue for quite sometime.
I tried a number of work-arounds for the previous code, but to no success. So I have got back to the conventional way of using saveOrUpdate, as follows:

Session session = this.getSession();
session.beginTransaction();
session.load(VulTable.class, transientInstance.getId());
session.saveOrUpdate(transientInstance);
session.getTransaction().commit();

But still I have the same problem, ie after 2/3 updates, the data fetched is not the latest.
I think it has got to do with the hibernate session, which does not always gets updated (or stops updating after few updates are made continuously).

Also there's another thing which I have noticed. I performed a small test. Just after the transaction is committed, and I try to fetch the data using the id(using findById function in the DAO), I get the appropriate data.
[I call the findById function from the saveOrUpdate function of the DAO itself, after the transaction is committed.]
But, when I try to fetch the data from the Action class of the UI, using the same findById function of the DAO, I dont always get to see the latest data.

Also, I have tried with both JDBC and JTA transaction, but have the same problem.

Please suggest.

==================
Devesh Chanchlani
==================
"The best ammunition is a load of ambition fired with effort towards a definite goal."
reply
    Bookmark Topic Watch Topic
  • New Topic