-->
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.  [ 6 posts ] 
Author Message
 Post subject: Case insensitive property names?
PostPosted: Tue Feb 21, 2006 11:54 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
Hibernate version:
3.0.5
The generated SQL (show_sql=true):
Hibernate: select hibernatep0_.iddb as iddb, hibernatep0_.name as name6_, hibernatep0_.packageid as packageid6_, hibernatep0_.processdefinitionid as processd4_6_, hibernatep0_.processdefinitionversion as processd5_6_, hibernatep0_.processdefinitioncreated as processd6_6_, hibernatep0_.state as state6_ from processdefinitions hibernatep0_ where PackageId='test_bs' order by ProcessDefinitionCreated ASC

code:
session.createQuery("from HibernateProcessMgr where "+sqlWhere).list(); //sqlWhere="PackageId='test_bs' order by ProcessDefinitionCreated ASC"


Is it possible to have hsql do a insensitive check on property name. I get a 'sqlwhere' statement where properties are in a upper/lower case mix. I need to have hibernate do a query based on this statement. Unfortunately, i have no control on the generation of this sqlWhere statement, i have to manage with it. Is it possible to have hsql perform a case insensitive comparaison of property names or do i have to write code (and lots of such code) to convert propertynames to their correct value (like PackageId -> packageId)?

Help greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 11:35 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
SQL isn't case sensitive, there should be no problem doing what you want (so long as there are no joins causing one of your sqlWhere column names to be duplicated involved). Are you currently getting an error? What is it?

BTW I presume that you meant HQL when you wrote hsql. HSQL is the dialect of SQL used by HSQLDB, which is not related to Hibernate (though it is fully supported by Hibernate).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 8:17 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
Yes i meant hql. Sorry for mistake.

my problem is, it's the names of object properties, not names of corresponding db field.

For example, some classe have properties that are mapped to bd fields with different name. My methods receives a "PackageId='test_bs' order by ProcessDefinitionCreated ASC" sql where clause, this aim the object properties names, not at the sql table.

So i need hql to do the propertyname -> fieldname mapping while not taking care of case in propertyname

btw, doesn't SQL request the alias of table be used inside where clause? (That is hql should generate 'where hibernatep0_.PackageId='test_bs' for query to work)

Errors during my attempt varied from sql grammar errror to empty result.

Was just hoping such case insensitiveness option existed.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 8:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you can do your own incasesensitive lookup for property names in the Configuration/ClassMetaData api if you really want this...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 9:14 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
I suppose you mean going in class metadata, get list of properties, for each property, check if they are present in my where String, do the replacement and then only do issue the session.createQuery() :s
Was hoping to not have to code a query parser for the transformation.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 9:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well, its you who want random string matching, so it will cost you.

_________________
Max
Don't forget to rate


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