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.Get() cannot retreive object while query can
PostPosted: Thu Aug 03, 2006 2:26 pm 
Beginner
Beginner

Joined: Wed Dec 28, 2005 3:14 pm
Posts: 29
I experienced a strange (to me) behavior from session.
I have a object Foo f already saved to the database ( the row is there) way before. The weird thing is that a session cannot Get or Load it, while the query created by the same session can retrieve it by query the Id.
the session cannot Get or Load the object by id until one of the following action was taken:
1) use a IQuery created by the same session to query the object.
2) close this session and start a new one.

session.Flush() has no effect over this.
Does anyone has any clue of the reason of this?
Many thanks in advance!


Hibernate version:1.2.1 alpha


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


ITransaction t = session.BeginTransaction();

Foo f = session.Get(1);
Assert.IsNull(f); //Get can not find the f with id = 1

f = (Foo)session.CreateQuery("from Foo f where f.Id = 1").UniqureResult();
Assert.IsNotNull(f); //however the Query can

f = session.Get(1);
Assert.IsNotNull(f) // Now session also can get the f


t.Commit();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 8:07 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
That's definitely strange. Can you post the mapping files, the classes, and the actual code?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 10:16 am 
Beginner
Beginner

Joined: Wed Dec 28, 2005 3:14 pm
Posts: 29
sergey wrote:
That's definitely strange. Can you post the mapping files, the classes, and the actual code?

Let me take some time extracting the problematic code. It's not a simple error. That behavior does not always happen, but quite often. I will post the detail later.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 05, 2006 2:15 am 
Beginner
Beginner

Joined: Wed Dec 28, 2005 3:14 pm
Posts: 29
sergey, I spent some hours created a test project to expose this strange behavior. This test now garuntee the strange behavior always happen with minimum code (still quite complex though). The package was 2.2mb. I couldn't attach it here, so I took the liberty creating a new jira issue about this and attach the test project there:
http://jira.nhibernate.org/browse/NH-687
Thanks,


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.