I checked the source code and found the piece of code which is causing the issue:
1) DefaultFlushEntityEventListener: private void checkNaturalId( EntityPersister persister, EntityEntry entry, Object[] current, Object[] loaded, EntityMode entityMode, SessionImplementor session){ //piece of code if ( !persister.getIdentifierType().isEqual( id, oid, entityMode, session.getFactory() ) ) { throw new HibernateException( "identifier of an instance of " + persister.getEntityName() + " was altered from " + id + " to " + oid ); }
2) public final class EqualsHelper {
public static boolean equals(Object x, Object y) { return x==y || ( x!=null && y!=null && x.equals(y) ); }
private EqualsHelper() {}
}
Here we don't trim the values which is causing the issue.
I checked the source code and found the piece of code which is causing the issue:
1) DefaultFlushEntityEventListener:
private void checkNaturalId(
EntityPersister persister,
EntityEntry entry,
Object[] current,
Object[] loaded,
EntityMode entityMode,
SessionImplementor session){
//piece of code
if ( !persister.getIdentifierType().isEqual( id, oid, entityMode, session.getFactory() ) ) { throw new HibernateException( "identifier of an instance of " + persister.getEntityName() + " was altered from " + id + " to " + oid ); }
2) public final class EqualsHelper {
public static boolean equals(Object x, Object y) { return x==y || ( x!=null && y!=null && x.equals(y) ); }
private EqualsHelper() {}
}
Here we don't trim the values which is causing the issue.