-->
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.  [ 1 post ] 
Author Message
 Post subject: Backticks/quotes not resolved/converted in SQLCriterion
PostPosted: Sat Mar 18, 2006 1:10 pm 
Newbie

Joined: Tue Feb 21, 2006 10:34 am
Posts: 7
I have found out that when using SQLCriterion class (Expression.sql() or Restrictions.sqlRestriction()) backticks/quotes are not resolved. So it is basically on developer to provide right backticks/quotes when needed.
Code:
Expression.sql("({alias}.`start` + {alias}.`duration`) BETWEEN " + (startTime / 1000) + " AND " + (endTime / 1000))


It is ok as far as you are using one database in your application. My application needs to use two DBs - MySQL and HSQLDB; for MySQL I have to use ` and for HSQLDB I have to use ".

I am looking for a universal way how to say Hibernate to convert backticks/quotes in sql expression to the right dialect.

I have looked into the source files of SQLCriterion class and it is true that it only replaces "{alias}" string into rigt name, but that is all.

I am going to handle this by getting quote characters from curently selected dialect (Dialect.getDialect() + openQuote() and closeQuote()) and modify SQL expression everytime it is going to be used, however it would be nice if this would have been done automatically done by Hibernate.

I might be looking into wrong place, is there any way how to solve this problem? If not, please consider this as proposal for enhancement.

Thanks in advance for any comment or idea.
.md


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.