-->
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: Restriction for String length (see Restrictions.sizeEq)
PostPosted: Fri May 16, 2008 3:58 am 
Newbie

Joined: Fri May 16, 2008 3:46 am
Posts: 1
Hi guys,

I have a question about creating a criteria. My current criteria looks like this:

Code:
final DetachedCriteria criteria = DetachedCriteria.forClass(AnyClass.class)
                .add(Restrictions.ge("validTo", TODAY))
                .add(Restrictions.le("validFrom", TODAY))
                .addOrder(Order.asc("shortName"));


This criteria works fine. but now i want an additional criteria which theoretically looks like this

Code:
final DetachedCriteria criteria = DetachedCriteria.forClass(AnyClass.class)
                .add(Restrictions.ge("validTo", TODAY))
                .add(Restrictions.le("validFrom", TODAY))
                .add(Restrictions.sizeEq("shortName", 4))    <--- LOOK HERE
                .addOrder(Order.asc("shortName"));


the problem is that sizeeq does not support size resp length of a string..only size of a collection.. and this is exactly what i dont want! how can i do it in hibernate?!

in java it would look like this:
shortName.length() == 4

... Please help me.

------------------------------------------------------------------------------

Hibernate version: 3.2.5

Full stack trace of any exception that occurs:

org.springframework.orm.hibernate3.HibernateSystemException: Unknown collection role.

=> This exception occurs because of misusing
Code:
sizeEq


Name and version of the database you are using: ORACLE 10g


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 16, 2008 8:43 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
forget this post.... my solution was wrong... sorry


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 20, 2008 8:06 am 
Newbie

Joined: Tue May 20, 2008 7:07 am
Posts: 1
typhos wrote:
forget this post.... my solution was wrong... sorry


I'm a fish,have the same problem like yours.
I wonder your right solution


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.