-->
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.  [ 4 posts ] 
Author Message
 Post subject: criteria api and simple math
PostPosted: Tue May 03, 2005 11:48 pm 
Beginner
Beginner

Joined: Tue May 03, 2005 11:45 pm
Posts: 43
Is it possible to do simple column math with the criteria api? I have a float column which I'd like to add or subtract a fixed value to. I suppose that an add(Restrictions.sql()) might work for what I need.

I'm using Hibernate 3.


Top
 Profile  
 
 Post subject: clarification
PostPosted: Wed May 04, 2005 11:09 am 
Beginner
Beginner

Joined: Tue May 03, 2005 11:45 pm
Posts: 43
Here is further clarification on my problem. Here is my table:

Address
---------

line1 varchar
line2 varchar
city varchar
state varchar
distance float
.
.
.


I want to do a query and within that query use criteria something like this:

where distance - x < 50

x is a fixed amount I want to subtract


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 11:26 am 
Newbie

Joined: Wed Aug 11, 2004 7:01 am
Posts: 10
How about doing som simple math...
Converting
where distance - x < 50
To
where distance < (50 + x)

eg
Restrictions.lt("distance", 50+x);

/Kristoffer


Top
 Profile  
 
 Post subject: yes
PostPosted: Wed May 04, 2005 11:40 am 
Beginner
Beginner

Joined: Tue May 03, 2005 11:45 pm
Posts: 43
I've thought of that but I'm also using setFirst(offset) and setMaxResult(page_size). I'm trying to just get 1 page of results and also avoid any post resultset processing.

Thanks


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