-->
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: Please help! How to use the to_char in criteria?
PostPosted: Sat Dec 13, 2008 7:28 pm 
Newbie

Joined: Sat Dec 13, 2008 7:16 pm
Posts: 2
Hello All,

How do I represent the following query in Hibernate using criteria? The problem being a.Col1 is a number field in database and cannot be changed and the input value is a string from java.

Code:
select * from TABA a where CHAR(a.Col1) like '6%'


Top
 Profile  
 
 Post subject: Re: Please help! How to use the to_char in criteria?
PostPosted: Mon Dec 15, 2008 3:40 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
sunilks wrote:
Hello All,

How do I represent the following query in Hibernate using criteria? The problem being a.Col1 is a number field in database and cannot be changed and the input value is a string from java.

Code:
select * from TABA a where CHAR(a.Col1) like '6%'



You can use :
Code:
String sql = "CHAR(a.Col1) like '6%';
crit.add(Restrictions.sqlRestriction(sql));


Top
 Profile  
 
 Post subject: Thanks!
PostPosted: Wed Dec 24, 2008 10:50 am 
Newbie

Joined: Sat Dec 13, 2008 7:16 pm
Posts: 2
Thanks SIau_Tie, the solution really did help and sorry couldn't reply earlier.


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.