-->
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: Datetime format
PostPosted: Mon Nov 03, 2003 10:40 pm 
Newbie

Joined: Mon Nov 03, 2003 10:29 pm
Posts: 1
i am using PostgreSQL database.
Here is my problem:
i want to use sql datatime functions like "EXTRACT" with hibernate.
but hibernate seems not to support those functions.
How could i do ?

for Example, here is my sql :
SELECT
EXTRACT(month form TIMESTAMP show_datetime) as month,
count(*) as count
FROM tbl_test
GROUP BY EXTRACT(month form TIMESTAMP show_datetime)

How can i use the sql above in hibernate ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2003 12:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Well, first, Hibernate uses HQL against objects; not SQL against tables.

How about using the SQL Extension function instead of the database specific function:

SELECT {fn MONTH(o.myDateTime)}, count(*) from MyObject as o GROUP BY {fn MONTH(o.myDateTime)}


Top
 Profile  
 
 Post subject: SQL Extensions
PostPosted: Mon Jan 30, 2006 5:18 pm 
Newbie

Joined: Mon Dec 27, 2004 5:38 pm
Posts: 8
I am using {fn.. } but got an error :
16:09:50,982 INFO [STDOUT] net.sf.hibernate.QueryException: undefined alias: {fn [select {fn MONTH(view.firstAlert)}, count(*) from UserView as view group by {fn MONTH(view.firstAlert)}]
at net.sf.hibernate.hql.PathExpressionParser.token(PathExpressionParser.java:103)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:170)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114)
at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
......


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.