public Difference compare(Object left, Object right, boolean onlyFirstDifference, ReflectionComparator reflectionComparator) {
if (isUninitialized(left) && isUninitialized(right)) {
String leftType = getEntitiyName(left);
String rightType = getEntitiyName(right);
if (leftType == null || !leftType.equals(rightType)) {
return new ObjectDifference("Different hibernate proxy types. Left: " + leftType + ", right: " + rightType, left, right);
}
Object leftIndentifier = getIdentifier(left);
Object rightIdentifier = getIdentifier(right);
Difference identifierDifference = reflectionComparator.getDifference(leftIndentifier, rightIdentifier, onlyFirstDifference);
if (identifierDifference != null) {
ObjectDifference difference = new ObjectDifference("Different hibernate proxy values", left, right);
difference.addFieldDifference("<proxy id>", identifierDifference);
return difference;
}
return null;
}