-->
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: Using sql functions in filter definitions
PostPosted: Wed Jul 13, 2005 3:48 pm 
Beginner
Beginner

Joined: Thu Jun 02, 2005 5:09 am
Posts: 22
Hi,

I have a filter definition with a clause that looks something like this (for CloudScape):

"CURRENT_TIMESTAMP < TABLENAME_EFFECTIVITY_END"

This filter works as expected: the CURRENT_TIMESTAMP is inserted literally in the WHERE clause since it's a SQL function and the TABLENAME_EFFECTIVITY_END is correctly interpreted as a column name.

However, when I change the function to "CURRENT TIMESTAMP" so DB2 7.2 will understand it (with a space instead of an underscore), Hibernate 3.05 mistakes the CURRENT for a column name and generates a WHERE clause that looks something like

where prefix0_.CURRENT TIMESTAMP < prefix0_.TABLENAME_EFFECTIVITY_END

Thus, DB2 can't parse the resulting SQL.

I need a way to tell Hibernate to leave the "CURRENT TIMESTAMP" text alone since it's a SQL function, and to not interpret the first part as a (non-existent) column.
Is there currently such a way (docs don't mention it) and if not, could this be added as a feature? Maybe by placing the text between back ticks in the definition, like in other parts of the mapping file?

Joris


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 6:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It might be worth submitting this to JIRA, since we could special-case it in the SQL parser.

A workaround would be to create a UDF called current_timestamp() and use that instead.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 6:43 pm 
Beginner
Beginner

Joined: Thu Jun 02, 2005 5:09 am
Posts: 22
gavin wrote:
It might be worth submitting this to JIRA, since we could special-case it in the SQL parser.


OK, I filed an issue. I registered it as a bug, though it could be considered an improvement:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-736

I'll have a go with the user-defined function for now.

Tnx,

Joris


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.