开发者

hibernate where clause with projection

开发者_开发技巧There's a table name STUDENTS with column studentName and studentID

I want to run a query like

SELECT studentName 
FROM STUDENTS 
WHERE studentId ='1'; 

in hibernate criteria and want to save this result in some String variable


Something like:

String result = (String)sess.createCriteria(Students.class)
    .add(Restrictions.eq("studentId",1))
    .setProjection(Property.forName('studentName'))
    .uniqueResult();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜