เกียร์ของฉัน:
ไฮเบอร์เนต 3.6.9
ภาษาถิ่น SQLite ไฮเบอร์เนตจาก http://code.google.com/p/hibernate-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 the uuid? - person andih   schedule 15.04.2012