我的装备:
休眠 3.6.9
来自http://code.google.com/p/hibernate-sqlite/的休眠 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'
结果是正确的(即从数据库中选择了一条记录)。
我有点难过,尝试了一切都没有结果......