I have the following query, trying to fetch Employee entity objects using part of the @Embeddable id class:
public List<EmployeeTask> getEmployeeById(){
return em.createQuery("SELECT a FROM EmployeeTask a where a.id.empcode = '5091'" ).getResultList();
The code above returns null on my jsf page. But when i change this to :
public List<EmployeeTask> getEmployeeById(){
return em.createQuery("SELECT a FROM EmployeeTask a where a.id.empcode like '5091'" ).getResultList();
again it returns null. But when i try:
public List<EmployeeTask> getEmployeeById(){
return em.createQuery("SELECT a FROM EmployeeTask a where a.id.empcode like '5091%'" ).getResultList();
}
it returns the contents of the Entity object as expected... Anyone knows why this happens?
More details on what i need to do: the EmployeeTask table contains all tasks performed by the employee. EmployeeTaskPK is string empcode, string taskcode, date since. I want to fetch all records for a given empcode in my Entity instance and list them on a jsf datatable.
Thank you,