工作我的装备:从http://code.google.com/p/hibernate-sqlite/休眠条件不SQLite的
我的实体类是简单
的Hibernate 3.6.9
休眠SQLite的话,
@Entity @Table(name = "RegistrationRequests") public class RegistrationRequest { @Id @GeneratedValue Integer id; String uuid; ... getters and setters ... }
将uuid分配给UUID.randomUUID()。toString(),并正确保留在数据库中。 现在,问题是当我尝试使用Hibernate Criteria从数据库检索存储的请求时。
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(RegistrationRequest.class); criteria.add(Restrictions.eq("uuid", '\'' + uuid + '\'')); List requests = criteria.list();
总是产生一个空的结果,但是,如果我执行生成的SQL,
select this_.id as id2_0_, this_.created as created2_0_, this_.email as email2_0_, this_.isVerified as isVerified2_0_, this_.name as name2_0_, this_.password as password2_0_, this_.surname as surname2_0_, this_.uuid as uuid2_0_ from RegistrationRequests this_ where this_.uuid='ced61d13-f5a7-4c7e-a047-dd6f066d8e67'
结果是正确的(即一个记录从数据库中选择)。
我有点为难,试图没有结果一切......
的' '\' '+ UUID + '\'''看起来很奇怪。如果你使用uuid而没有'arround uuid?会发生什么? – andih 2012-04-15 19:44:58