Skip to content

Commit f092c4e

Browse files
committed
DATAJPA-716 - Strengthened tests for updatability detection in JpaPersistentProperty.
Added negative check, too, and tweaked implementation to actually correctly detect the updatability.
1 parent 886120e commit f092c4e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ private final boolean detectUpdatability() {
292292

293293
Annotation annotation = findAnnotation(annotationType);
294294

295-
if (annotation != null && AnnotationUtils.getValue(annotation, "updateable") == Boolean.TRUE) {
296-
return true;
295+
if (annotation != null && AnnotationUtils.getValue(annotation, "updatable").equals(Boolean.FALSE)) {
296+
return false;
297297
}
298298
}
299299

300-
return false;
300+
return true;
301301
}
302302
}

src/test/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImplUnitTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ public void considersTargetEntityTypeForPropertyType() {
188188
@Test
189189
public void considersNonUpdateablePropertyNotWriteable() {
190190
assertThat(getProperty(WithReadOnly.class, "name").isWritable(), is(false));
191+
assertThat(getProperty(WithReadOnly.class, "updatable").isWritable(), is(true));
191192
}
192193

193194
private JpaPersistentProperty getProperty(Class<?> ownerType, String propertyName) {
@@ -311,5 +312,6 @@ static class Implementation {}
311312

312313
static class WithReadOnly {
313314
@Column(updatable = false) String name;
315+
String updatable;
314316
}
315317
}

0 commit comments

Comments
 (0)