-->
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.  [ 2 posts ] 
Author Message
 Post subject: Why ISession.Get doesn't work?
PostPosted: Thu Jan 11, 2007 4:00 am 
Newbie

Joined: Thu Jan 11, 2007 3:49 am
Posts: 1
Location: Finland
Hi all!

I have fetching problem. I try to get data with ISession.Get method, but it always returns null. If I use ISession.Find instead and give it the same id I gave the Get method it works and gets the row I wanted. My Id field is of type DateTime (I know it seems alerting, but please trust me, I know what 'm doing..) and I set it as 'assigned' so that I must set it myself every time I do Insert.

So, here's the pseudo for these two methods I tried:
Code:
//1st way: Get method:
DateTime id = DateTime.Now;
MyClass instance = (MyClass)session.Get(typeof(MyClass), id);
//Here the instance is null even it should be in the db..

//2nd way: Find method:
DateTime id = DateTime.Now;
IList list = session.Find("from MyTable WHERE Id = '" + id.ToString() + "'");
MyClass instance = (MyClass)list[0];
//Here the instance is okay!

So, what could be wrong is it that the Id field is DateTime? Or is there something I just don't see?

Thank You!

Yours,

Arto Kainu[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 5:24 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
DateTime.Now probably has more precision than DateTime.Now.ToString() (for example, DateTime.Now may include microseconds while its string representation does not).


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