Leverage the equal() method on the wrapped entity instead of creating a string.

Closes #11764
This commit is contained in:
Alexander Schwartz 2022-04-29 11:35:08 +02:00 committed by Hynek Mlnařík
parent 0d83b51b20
commit e0d7ad1be5

View file

@ -258,20 +258,14 @@ public class JsonbType extends AbstractSingleColumnStandardBasicType<Object> imp
try {
return MAPPER.writeValueAsString(value);
} catch (IOException e) {
throw new HibernateException("unable to tranform value: " + value + " as String.", e);
throw new HibernateException("unable to transform value: " + value + " as String.", e);
}
}
@Override
public boolean areEqual(Object one, Object another) {
if (one == another) return true;
if (one == null || another == null) return Objects.equals(one, another);
try {
return MAPPER.readTree(toString(one)).equals(
MAPPER.readTree(toString(another)));
} catch (IOException e) {
throw new HibernateException("unable to perform areEqual", e);
}
return Objects.equals(one, another);
}
}
}