Strong Liu commented on Bug HHH-6204

I have some analysis on this issue:

when initialising an EntityKey (with this constructor public EntityKey(Serializable id, EntityPersister persister, EntityMode entityMode)), somehow, the serializable id instance is actually the Entity (with embedded id) instance itself, and identifierType get by `this.identifierType = persister.getIdentifierType();` is correct – the embedded id type.

the method org.hibernate.engine.EntityKey#generateHashCode is called during initialising time, and it then calls `identifierType.getHashCode( identifier, entityMode, factory )`

since identifierType is actually ComponentType, so, in the method getHashCode, this class will using getters to get each filed values from identifier, then there is a type mismatch happens, the identifier type here is supposed to be the embedded pk instance, which it is actually the entity class instance.

so, the https://gist.github.com/3164408 exception throws

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira