I faced the problem having some entities with embedded keys. When referencing this entities by ManyToOne and simple String-type JoinColumn (other than the keys ! ) I got the error (or some error very similar to the above). Some analysis work resulted to the theory that if an entity has an embedded key this key will ever be used as defining the relation type and NOT the type of the property which is used to define the relation. My proposed Solution (which works for me at several tests, but is of course subject to be check by the community) is a change of Method ManyToOneType.isDirty(Object, Object, SharedSessionContractImplementor): @Override public boolean isDirty(final Object old, final Object current, final SharedSessionContractImplementor session) throws HibernateException { if (isSame(old, current)) { return false; } if (uniqueKeyPropertyName != null) { EntityPersister entityPersister = getAssociatedEntityPersister(session.getFactory()); String identifierOrUniqueKeyPropertyName = getIdentifierOrUniqueKeyPropertyName(session.getFactory()); if (identifierOrUniqueKeyPropertyName != null) { Object oldPropertyValue = entityPersister.getPropertyValue(old, identifierOrUniqueKeyPropertyName); Object currentPropertyValue = entityPersister.getPropertyValue(current, identifierOrUniqueKeyPropertyName); Type idOrUniType = entityPersister.getPropertyType(identifierOrUniqueKeyPropertyName); return idOrUniType.isDirty(oldPropertyValue, currentPropertyValue, session); } } Object oldid = getIdentifier(old, session); Object newid = getIdentifier(current, session); return getIdentifierType(session).isDirty(oldid, newid, session); } |