-->
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.  [ 1 post ] 
Author Message
 Post subject: Bind values for Criteria queries ...
PostPosted: Mon May 05, 2008 5:25 pm 
Newbie

Joined: Mon May 05, 2008 4:57 pm
Posts: 1
Hibernate version: 3.2.5

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

Is there a way to bind a value in a Criteria query?

I would like to perform something like the following:

Date user_date = <user supplied date>
Criteria criteria = Criteria.createCriteria( "cats" );
criteria.setProjection( Projections.sqlProjection( "abs( create_date - ? )" ) );
criteria.setDate( user_date );
List result = criteria.list();

The code above is an example of the issue I am having with criteria queries. There is no "setDate()" method on Criteria (although I wish there was).

I want result to contain create_dates, a per row value, relative from user_date, a value supplied from the user.

- I have a strong preference for bind values over embedding values directly in SQL expressions.
- I would prefer to not use HQL.

Any input? Is there another way to do this? Is it possible to bind values with Criteria queries??

- Aaron


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.