public class UserCustomerMappingId implements Cloneable, Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
private String userName = null;
private String companyId = null;
private String customerId = null;
public UserCustomerMappingId()
{
super();
}
// getters and setters omitted for brevity
}
The above works perfectly on 5.0, but encounters the below MappingException when run deployed on 5.3. This occurs while the PersistenceUnit is starting.
org.hibernate.MappingException: property [id.companyId] not found on entity [...UserCustomerMapping]
I have made no other source nor configuration changes, What am I missing or do I need to change to make the above work with 5.3 please?
I have checked and doubled checked that all of the properties are identically declared between the @Entity and the @IdClass. I am not sure why it is looking for the companyId as a sub-attribute of “id” as there is no “id” in either the @Entity or @IdClass.
Is there any way to get Hibernate to provide more specific information regarding the specific source of the error (i.e. where it is looking for id.companyId from)?
I have recently discovered that the org.hibernate.MappingException can be avoided if I remove the @Index annotation from the @Id attributes in the @Entity class. This combination if @Id and @Index has worked well for me in Hibernate 5.0, but appears to be problematic in 5.3 (albeit not so obviously by the error message).
Can anyone shed any light on why this combination is now an issue? Additionally, I want t have a named index on these columns, how can I restore the combination of the two annotations without encountering the MappingException?
I would still like to understand why the combination of @Id and @Index is no longer working. However, I have found a way to still declare the desire to have these indexes by specifying them as part of the @Table annotation.
As you can read in the issue ([HHH-14534] Index annotation causing Runtime failure - Hibernate JIRA) using @Table is the way to go and also a description of why this stopped working. Since the Hibernate @Index annotation is deprecated you should move away from this approach anyway.