Reputation: 11201
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
Upvotes: 4
Views: 16056
Reputation: 423
Something like:
String result = (String)sess.createCriteria(Students.class)
.add(Restrictions.eq("studentId",1))
.setProjection(Property.forName('studentName'))
.uniqueResult();
Upvotes: 5