-->
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.  [ 8 posts ] 
Author Message
 Post subject: Oracle lower()
PostPosted: Thu Jul 20, 2006 2:37 am 
Newbie

Joined: Fri Jul 14, 2006 3:19 am
Posts: 12
Hi

I have a problem with the function lower() from Oracle.

my code:

Code:
Criteria criteria = session.createCriteria(getStoredClass()).add(Restrictions.like("lower('"+field+"')",argument.toLowerCase()+"%"));


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 2:49 am 
Newbie

Joined: Tue Mar 22, 2005 6:01 pm
Posts: 13
Location: Sydney, Australia
What error are you getting?
Are you sure you don't mean to do:

add(Restrictions.like(argument.toLowerCase(),"lower('"+field+"')||'%'"));


Last edited by jaqel on Thu Jul 20, 2006 2:54 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 2:50 am 
Newbie

Joined: Fri Jul 14, 2006 3:19 am
Posts: 12
next


Last edited by darksmilie on Thu Jul 20, 2006 2:52 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 2:51 am 
Newbie

Joined: Fri Jul 14, 2006 3:19 am
Posts: 12
org.hibernate.QueryException: could not resolve property: lower(nname) of:

nname is the fieldname from the table


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 2:59 am 
Newbie

Joined: Tue Mar 22, 2005 6:01 pm
Posts: 13
Location: Sydney, Australia
ah forget what i wrote up above...

when you add a criteria expression the first parameter must be a property name in the target class.

I don't think you can do what it is that you want with criteria expression.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 3:58 am 
Newbie

Joined: Fri Jul 14, 2006 3:19 am
Posts: 12
I think it goes but i become only a java.lang.NullPointerException

Code:
Criteria criteria = session.createCriteria(getStoredClass()).add(Restrictions.sqlRestriction("lower({"+field+"}.name) like lower("+argument+"%)"));


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 5:03 am 
Newbie

Joined: Fri Jul 14, 2006 3:19 am
Posts: 12
It runs :)

Code:
Criteria criteria = session.createCriteria(getStoredClass()).add(Restrictions.sqlRestriction("lower("+field+") like lower(?)",argument.toLowerCase()+"%",Hibernate.STRING));


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 11:39 pm 
Newbie

Joined: Tue Mar 22, 2005 6:01 pm
Posts: 13
Location: Sydney, Australia
Goods stuff...

Of course using SqlRestriction you can do cool stuff like that.


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