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); criteria.add(Property.forName("pantry").eq(pantry)) .createCriteria("foodServing.food") .add(Restrictions.like("title", freetext, MatchMode.ANYWHERE)) .add(Restrictions.ne("class", Recipe.class)) .addOrder(Order.asc("title"));
This produces the following SQL (no problem here):
select this_.pantry_food_id as pantry1_20_1_, this_.pantry_id as pantry2_20_1_, this_.food_id as food3_20_1_, ... from pantry_food this_ inner join food food1_ on this_.food_id=food1_.food_id where this_.pantry_id=? and food1_.title like ? and food1_.FOOD_TYPE_CODE<>? order by food1_.title asc
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?
|