Hibernate version: 3.1.3
database: Oracle 10g
I've got a DetachedCriteria query as follows (note the Restrictions.ne("class"...):
DetachedCriteria criteria = DetachedCriteria.forClass(PantryFood.class);
.add(Restrictions.like("title", freetext, MatchMode.ANYWHERE))
This produces the following SQL (no problem here):
this_.pantry_food_id as pantry1_20_1_,
this_.pantry_id as pantry2_20_1_,
this_.food_id as food3_20_1_,
and food1_.title like ?
The problem appears with the value that gets bound to the "class" restriction-- RECIPE, which is the correct discriminator value, is wrapped in two sets of singlequotes rather than just one:
13030 [2008-06-11 11:59:38,442] [main] DEBUG org.hibernate.type.LongType - binding '55276' to parameter: 1
13030 [2008-06-11 11:59:38,442] [main] DEBUG org.hibernate.type.StringType - binding '%cheese%' to parameter: 2
13046 [2008-06-11 11:59:38,458] [main] DEBUG org.hibernate.type.StringType - binding ''RECIPE'' to parameter: 3
I suppose I can do something similar with a sqlRestriction, but I'd love to understand why this is happening. Can anyone clarify?