-->
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.  [ 5 posts ] 
Author Message
 Post subject: Help with Criteria/HQL and java.sql.Time property
PostPosted: Mon Aug 08, 2005 6:05 pm 
Beginner
Beginner

Joined: Tue Dec 21, 2004 11:53 am
Posts: 42
Hello there! I'm having some problems when dealing with java.sql.Time properties. My Database is a SQL Server 2000 with a DateTime column. My property is mapped as a java.sql.Time

My problem is, when I create a criteria I'm doing this:

Criteria c = session.createCriteria(Entity.class);
c.add(Expression.gt("beginTime", timeObject);

But what is being generated on the SQL is column_name > '10:00:00' (suppose our timeObject maps to a date at 10 o'clock).

Any hints on how to use it?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 6:12 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
What is your exact problem?
Why don't you use java.util.Date?

Best regards
Sven


Top
 Profile  
 
 Post subject: datetime
PostPosted: Mon Aug 08, 2005 7:03 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
If your column is DateTime then I suppose that you are interested in date AND time. Then just map the column to the property of type java.util.Date and averything shoulld work.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 7:31 am 
Beginner
Beginner

Joined: Tue Dec 21, 2004 11:53 am
Posts: 42
Hello Konstantin! r u the same guy from Hivemind list? Dude you are everywhere ;).

Well my problem isn't with the mapping it self. The issue is, on the database I have only time recorded, like 10:15:00. I need to fetch data that meets a given criteria, like "fetch all data that the time is before now" problem is now, is a "complete" date object (mm/dd/yyyy HH:mm:ss). I was doing with a calendar object, but it required me doing a lot of conversion, and I could't filter anything from HQL.

What I'd like to know is how to work with only times on Hibernate.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 8:03 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
I'm not really into SQL Server 2000, but when using a DateTime in SQL Server 2000 you will have the whole date, not only the time, right?

So, you will have to convert this data type to only retrieve the time.

What is your expected result in SQL?

Best regards
Sven


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