休眠条件DetachedCriteria和子查询

时间:2018-11-20 17:23:39

标签: java hibernate subquery hibernate-criteria detachedcriteria

DetachedCriteria cr = DetachedCriteria.forClass(DealerSales.class).setProjection(Property.forName("dealerCode"));
cr.add(Restrictions.eq("countryCode",01));

Criteria cr1 = session.createCriteria(BrandModelSales.class).add(Subqueries.propertyIn("dealerCode",cr));

下面是一个例外:

SEVERE: Servlet.service() for servlet [spring] in context with path [/Scoreboard] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String] with root cause
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

其中dealecode作为数字存储在表中,而分离标准将其返回为String
cast()方法也不起作用.....
除了HQL和本机查询,还有其他方法吗?

0 个答案:

没有答案