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:
Oliver Gierke
2014-11-18 16:46:18 +01:00
parent 6a849bc8ef
commit 3446c457d5
2 changed files with 29 additions and 1 deletions

View File

@@ -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);
}
/*