Hibernate 5.3.7 issue for Composite keys

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.

I am not aware of such a setting and didn’t know this “feature”. Hibernate has an implicit “id” attribute which can be used to refer to the primary key though.

Yes. I assumed there isn’t any special setting in hibernate for the same. Therefore, i had to scan my entire project to see if any composite key has been referenced incorrectly.