i have a hibernate class:
class student{
string name;
int roll;
}
while fetching records i have a requirement where i need to fetch records where name = “john” OR name = “paul”, so basically i am trying to nget all records who have names as john or paul. I am not able to do the same. Please guide.
List students = sess.createCriteria(student.class)
.add( Restrictions.eq("name", "John") )
.add( Restrictions.eq("name", "Paul")) )
.list();
This is the non working code.
Try:
PS. I recommend you using QueryDSL than Criteria API.