任何人都可以指导我我要去的地方错了吗?它使零的结果,但在分贝值成为这次的情况会出现在下面的查询。
Str = QueryImpl(from ArcZipCodeRange where cast(fromZip as int) >='12345' and cast(toZip as int)<='12345')
arcZipCodeRangeList = 0
你确定你的条件是正确的?
cast(fromZip as int) >='12345' and cast(toZip as int)<='12345')
将给人以from
> 12345 to
<12345的所有结果。
它应该是周围的其他方式:from
<12345和to
> 12345?
您可以通过Hibernate Criteria
很容易地做到这一点。对于解决方案,你必须创建自己的这些(fromZip和toZip)Hibernate Formula
。下面一定是你的POJO映射。
@Column
private String fromZip;
@Formula(value="to_number(fromZip)")
private double newfromZip;
@Column
private String toZip;
@Formula(value="to_number(toZip)")
private double newtoZip;
以下是你的选择标准:
Criteria criteria = session.createCriteria(ArcZipCodeRange.class);
criteria.add(Restrictions.le("newfromZip", yourIntegerParameter));
criteria.add(Restrictions.ge("newtoZip", yourIntegerParameter));
List<ArcZipCodeRange> list = criteria.list();
我希望这能帮到您。