AbstractPersistentProperty now considers the owner for equals.
This makes a difference when a property is declared in a superclass of two entities. In such a case the property is the same, but the owner is different. Closes #2972 Original pull request #2973 See https://github.com/spring-projects/spring-data-relational/issues/1657
This commit is contained in:
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -41,6 +42,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>> implements PersistentProperty<P> {
|
||||
|
||||
@@ -87,7 +89,7 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
|
||||
this.association = Lazy.of(() -> isAssociation() ? createAssociation() : null);
|
||||
this.owner = owner;
|
||||
|
||||
this.hashCode = Lazy.of(property::hashCode);
|
||||
this.hashCode = Lazy.of(() -> Objects.hash(property, owner));
|
||||
this.usePropertyAccess = Lazy.of(() -> owner.getType().isInterface() || CAUSE_FIELD.equals(getField()));
|
||||
|
||||
this.isAssociation = Lazy.of(() -> ASSOCIATION_TYPE != null && ASSOCIATION_TYPE.isAssignableFrom(rawType));
|
||||
@@ -317,7 +319,7 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.property.equals(that.property);
|
||||
return this.property.equals(that.property) && this.owner.equals(that.owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user