DATAJPA-605 - JpaPersistentProperty implementation now detects JPA's @Version annotation.
Added override for JpaPersistentPropertyImpl.isVersionProperty() to also consider properties annotated with JPA's @Version annotation as version property. Related pull request: #108.
This commit is contained in:
@@ -32,6 +32,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.data.annotation.AccessType.Type;
|
||||
import org.springframework.data.annotation.Version;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link JpaPersistentPropertyImpl}.
|
||||
@@ -142,6 +143,22 @@ public class JpaPersistentPropertyImplUnitTests {
|
||||
assertThat(getProperty(CompetingPropertyLevelAnnotations.class, "id").usePropertyAccess(), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-605
|
||||
*/
|
||||
@Test
|
||||
public void detectsJpaVersionAnnotation() {
|
||||
assertThat(getProperty(JpaVersioned.class, "version").isVersionProperty(), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-605
|
||||
*/
|
||||
@Test
|
||||
public void detectsSpringDataVersionAnnotation() {
|
||||
assertThat(getProperty(SpringDataVersioned.class, "version").isVersionProperty(), is(true));
|
||||
}
|
||||
|
||||
private JpaPersistentProperty getProperty(Class<?> ownerType, String propertyName) {
|
||||
|
||||
JpaPersistentEntity<?> entity = context.getPersistentEntity(ownerType);
|
||||
@@ -241,4 +258,14 @@ public class JpaPersistentPropertyImplUnitTests {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
static class SpringDataVersioned {
|
||||
|
||||
@Version long version;
|
||||
}
|
||||
|
||||
static class JpaVersioned {
|
||||
|
||||
@Version long version;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user