-->
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: Named Param Substitution with Restrictions.sqlRestriction()
PostPosted: Wed Jun 30, 2010 10:12 am 
Newbie

Joined: Tue Jul 15, 2008 8:27 am
Posts: 12
Location: Germany
Hi there,

is there a way to employ named param substitution with Restrictions.sqlRestriction(String)?

Motivation:

I'd like to add parametrized SQL fragments to a Criteria-Query.

Example:

Code:
String mySQLFragment = "myColumn = :myParam";
   Citeria crit = session.createCriteria(myClass);
   crit.add(Restrictions.sqlRestriction(mySQLFragment);


Used Hibernate version: 3.3.2.GA

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

Alternatively, I tried to create an SQLQuery:

Code:
SQLQuery sQuery = session.createSQLQuery(mySQLFragment );


and called the substitution-Methods:

Code:
sQuery.setString(":myParam", someStringValue);


and tried to get the queryString via:

Code:
sQuery.toString() // or sQuery.getQueryString()


but both methods do not perform the substitution...

Furthermore a search on Google and in this Forum did not enlighten me in the least regarding this.

My point here is that I'd simply like to use Hibernate's knowledge of the current DB(-dialect) and use it perform the proper escaping etc. of special characters, and therefore spare me the work of deconstructing my filter-constructs in order to put them directly into criteria...

Any helpful comments would be highly appreciated.

Thanks a lot and cheers,
Arndt


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.