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.  [ 4 posts ] 
Author Message
 Post subject: session.find return stale data even after clear and evict
PostPosted: Thu Sep 02, 2004 8:42 am 
Newbie

Joined: Thu Sep 02, 2004 8:16 am
Posts: 4
As I am just expermenting with Hibernate I came to the following "weird" (forgive my ignorance) behaviour.

I am adding transient objects to a session without actually committing or rolling back a transaction. When closing the session, opening a new session and executing a find on this newly created session it returns me the non committed objects.

Any enlightment on this would be appreciated.

Kind regards


Hibernate version: 2.1.4 and 2.1.6

Mapping documents:

Code between sessionFactory.openSession() and session.close():

session = sessionFactory.openSession();

for (int i = 0; i < 10; i++) {
myClass = new MyClass("ricky");
session.saveOrUpdate(myClass );
session.evict(myClass );
}

session.clear();
session.flush();
session.close();

sessionFactory.evict(SystemEndpoint.class);

session = sessionFactory.openSession();

myClassList = session.find("from MyClass");
// returns the previously saved but non committed objects
for (Iterator iter = systemEndPointList.iterator(); iter.hasNext();) {
System.out.println(" --> " + iter.next());
}

session.close();


Name and version of the database you are using:
MySQL 4.0.20d


Top
 Profile  
 
 Post subject: updated typo in code example
PostPosted: Thu Sep 02, 2004 9:52 am 
Newbie

Joined: Thu Sep 02, 2004 8:16 am
Posts: 4
just providing a code update

session = sessionFactory.openSession();

for (int i = 0; i < 10; i++) {
myClass = new MyClass("ricky");
session.saveOrUpdate(myClass );
session.evict(myClass );
}

session.clear();
session.flush();
session.close();

sessionFactory.evict(SystemEndpoint.class);
// tried about everything to get rid of the saved objects on the session

session = sessionFactory.openSession();

myClassList = session.find("from MyClass");
// returns the previously saved but non committed objects
for (Iterator iter = myClassList.iterator(); iter.hasNext();) {
System.out.println(" --> " + iter.next());
}

session.close();


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 9:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I hope you are using InnoDB tables.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 10:11 am 
Newbie

Joined: Thu Sep 02, 2004 8:16 am
Posts: 4
Yes, I am using InnoDB tables to enable foreign key constraints


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