In our project, we have been using the hibernate xml configurations. Recently, I had upgraded my code from hibernate 3 to hibernate 5.3.7. Most of issues got resolved except below issue:
public class Employee implements Serializable{
private com.model.EmployeePK comp_id;
private String address;
private String phoneNumber;
// getter setters created and constructor is present for above fields
}
public class EmployeePK implements Serializable {
/** identifier field */
private Integer employeeName;
private Integer employeeNumber;
// getter setters created and constructor is present for above fields
}
I had been using below query while referring to this table to select records:
String hql = "from com.model.Employee aTable where
aTable.employeeNumber= :number ";
Here, in hibernate 3, this query works fine. However, in hibernate 5.3.7, this query throws an exception as hibernate not able to find employeeNumber( composite key) from the Employee entity.
To resolve the issue, i had to change the query and mention explicitly the composite key path in the query:
String hql = "from com.model.Employee aTable where
aTable.compId.employeeNumber= :number ";
Above query works fine in newer version.
I am putting this observation in forum to understand why I am seeing this behavior and is there any major changes made in the context which allows developer to explicitly declare composite keys in queries.
Is there any settings that can disable this behavior?
Looking forward to the discussion.