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