I can't figure out why this query isn't giving me any result. I know the data exists in the table.
The list variable "results" is empty when the query is executed. Am I implementing the composite key correctly?
I even tried using the @EmbeddedId to get this done but the returned list was still empty.
Session sess = HibernateUtil.getSession();
Criteria criteria = sess.createCriteria(Employee.class);
criteria.add(Restrictions.eq("employeeId", 255847208));
criteria.add(Restrictions.eq("serialId", 461));
List<Employee> results = criteria.list();
Primary key class
public class EmpPrmryKey implements Serializable {
private Integer employeeId;
private Integer serialId;
//getters and setters
}
POJO Mapped to Table:
@Entity
@IdClass(EmpPrmryKey.class)
@Table(name = "EMPLOYEE")
public class Employee{
private EmpPrmryKey compositeId;
@Id
@Column(name = "employee_id")
private Integer employeeId;
@Id
@Column(name = "serial_id")
private Integer serialId;
//getters and setters
}