DATACMNS-596 - Polishing.
PersistentEntityInformation now falls back to null values for PersistentEntity instances that don't expose an identifier property.
This commit is contained in:
@@ -18,6 +18,7 @@ package org.springframework.data.repository.core.support;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.model.BeanWrapper;
|
||||
import org.springframework.data.repository.core.EntityInformation;
|
||||
|
||||
@@ -49,7 +50,14 @@ public class PersistentEntityInformation<T, ID extends Serializable> extends Abs
|
||||
*/
|
||||
@Override
|
||||
public ID getId(T entity) {
|
||||
return (ID) persistentEntity.getPropertyAccessor(entity).getProperty(this.persistentEntity.getIdProperty());
|
||||
|
||||
PersistentProperty<?> property = persistentEntity.getIdProperty();
|
||||
|
||||
if (property == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (ID) persistentEntity.getPropertyAccessor(entity).getProperty(property);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user