-->
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: Stale data in session on MySQL
PostPosted: Thu Apr 07, 2005 4:17 am 
Newbie

Joined: Tue Oct 19, 2004 8:50 am
Posts: 2
We've got a problem with stale data in session. We islolated example code - in short it's doing this:

Opens 2 sessions at start. In 1st session display actual count of persisted objects, starts transaction and save new object into database. Then in 2nd session(!) displays actual count again.
Problem is that 2nd session doesn't see changes made by 1st session and shows same count.

I happens only on MySQL server. Same code runs correct on Informix (it outputs count 0 and then 1).

We tried disable caches in hibernate and similar experiments which came on our minds. Nothig helped.

So any good advice makes us happy. Thanks.


Hibernate version: 2.1.7

Mapping documents: Not important, code bellow fails always. We can use some "Worker.hbm.xml" for example.

Code:


Code:
try {
      SessionFactory sf = cfg.buildSessionFactory();
      Session s1 = sf.openSession();
      Session s2 = sf.openSession();

      List lst = s1.find("from Obec");
      System.out.println("1st count = " + lst.size());

      Transaction tx = s2.beginTransaction();
      Worker w = new Worker();
      o.setName("John");
      s2.save(o);
      tx.commit();

      s1.clear();
      List  lst2 = s1.find("from Obec");
      System.out.println("2st count = " + lst2.size());

      s1.close();
      s2.close();
}
catch (Exception ex) {
      ex.printStackTrace();
}



Name and version of the database: MySQL 4.0.20

The generated output - copied from log messages:

    DEBUG SQL:229 - select worker0_.id as id, worker0_.name as name from worker worker0_

    1st count = 0

    DEBUG SQL:229 - insert into worker(name, id) values (?, ?)

    DEBUG SQL:229 - select worker0_.id as id, worker0_.name as name, from worker worker0_

    2nd count = 0


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 11:47 am 
Newbie

Joined: Wed May 04, 2005 3:33 am
Posts: 6
Hmmmm i have the same issue with cocoon + 2.1.7c Hibernate and mysql 4.1. is there any solution to this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 8:43 am 
Newbie

Joined: Tue Oct 19, 2004 8:50 am
Posts: 2
As far as I can remember, we were not able to solve this problem. We migrated to PostgreSQL instead. So I am sorry, but I can't help you.

Best regards

Balaz Vladimir.


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.