DATAJPA-716 - Strengthened tests for updatability detection in JpaPersistentProperty.
Added negative check, too, and tweaked implementation to actually correctly detect the updatability.
This commit is contained in:
@@ -292,11 +292,11 @@ class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty<JpaPer
|
||||
|
||||
Annotation annotation = findAnnotation(annotationType);
|
||||
|
||||
if (annotation != null && AnnotationUtils.getValue(annotation, "updateable") == Boolean.TRUE) {
|
||||
return true;
|
||||
if (annotation != null && AnnotationUtils.getValue(annotation, "updatable").equals(Boolean.FALSE)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ public class JpaPersistentPropertyImplUnitTests {
|
||||
@Test
|
||||
public void considersNonUpdateablePropertyNotWriteable() {
|
||||
assertThat(getProperty(WithReadOnly.class, "name").isWritable(), is(false));
|
||||
assertThat(getProperty(WithReadOnly.class, "updatable").isWritable(), is(true));
|
||||
}
|
||||
|
||||
private JpaPersistentProperty getProperty(Class<?> ownerType, String propertyName) {
|
||||
@@ -311,5 +312,6 @@ public class JpaPersistentPropertyImplUnitTests {
|
||||
|
||||
static class WithReadOnly {
|
||||
@Column(updatable = false) String name;
|
||||
String updatable;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user