-->
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: How to give rtrim to a column name in a hibernate criteria
PostPosted: Wed May 23, 2007 6:10 am 
Beginner
Beginner

Joined: Thu May 17, 2007 9:56 am
Posts: 21
Location: India
Hi,

I want to write a Query using hibernte criteria as follows:

select * from <tableName> where rtrim(ColumnName) like '123';


But in criteria i don't know how to give ltrim(rtrim(columnName).

Can anyone help in this?

As the column is of type Char it is not working on DB side if i give simply 'like'. I need to give "rtrim(columnName) like' to retrieve the values.

_________________
Kuzhali


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 10:05 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi


Code:
List list=sess.createCriteria(DefaultValue.class).add( Restrictions.sqlRestriction("rtrim(field1) like ?", "Fie%", Hibernate.STRING) ).list();


Code:
List list=sess.createCriteria(DefaultValue.class).add( Restrictions.sqlRestriction("ltrim(rtrim(field1)) like ?", "Fie%", Hibernate.STRING) ).list();


Amila

(Don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 4:54 am 
Beginner
Beginner

Joined: Thu May 17, 2007 9:56 am
Posts: 21
Location: India
Hi,

It is helpful, but i don't want to use sql restrictions here.


My criteria looks like:

List list=sess.createCriteria(DefaultValue.class).add( Restrictions.like("empNm", new String ("tst")).

So, i will not be able to use sql criteria along with this.

Is it possible to handle it with Restrictions itself?

_________________
Kuzhali


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.