• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

client and server sharing same database - stale data problem

 
Piotrek Tempes
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I am writing a monitoring application witch I want to work in multi level tree topology, but lets simplify situation and reduce problem to client-server architecture... So I wish to have two applications sharing one database...

First application is about to collect various data and push them into database of server on which web interface will display those data in some charts, etc...

So here's the problem. If I have 2 applications working on same db I got stale data on my interface app... For example:

If first app is running code like this (let's assume on empty database):


and then I run the second one:


the first one is printing out still 0...

I have google for 5 hours and found some info about caching, transactional, multi-threading, etc... but none of googled hints worked...

My cfg:
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you run these two parts in two different threads simultaneously, are you talking about the first iteration of the loop or the entire life cycle in the first code snippet?
 
Piotrek Tempes
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
unfortunately entire lifycycle... And to make sure we understand correctly those aren't two threads of the same application (so I can't share sessions or sessionFactories). These are two separate applications... I don't know why but for some reason when I run first program (with first snippet) and then second program... The first one is still printing out 0... caching in mysql should be turned off... based on hibernate config file - hibernate caching also... even session object cache should be cleared due to session closing. I am stucked
 
Piotrek Tempes
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked that example on jdbc and it's working fine... running 2 tests simultaneously (one inserting and one reading data) brings actual data. The worst thing is that we've got pretty much code written and we need to fix that for this week... We are afraid that hibernate was the worst mistake in our life :/
 
Piotrek Tempes
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case someone had similiar problem:

it turned out that in case of sharing database by applications hibernate.connection.isolation should be accustomed to user needs... lowering isolation level resolved the problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic