Hibernate Restrictions.ilike遇到错误

时间:2013-06-18 06:31:28

标签: hibernate java-ee hibernate-mapping hibernate-criteria

执行以下限制会遇到以下错误

 Message: java.lang.String cannot be cast to java.lang.Integer

       if (suburbid > 0) {
            criteria.add(Restrictions.ilike("suburb.id", suburbid));
        } 

2 个答案:

答案 0 :(得分:0)

更改

criteria.add(Restrictions.ilike("address.subrub.id", suburbid));

criteria.add(Restrictions.ilike("suburb.id", suburbid));

<强>更新

还尝试更改

.createAlias("development.address.suburb", "suburb");

.createAlias("devAddress.suburb", "suburb");

答案 1 :(得分:0)

您不能使用Like进行整数更改为eq。