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:
Oliver Gierke
2014-11-10 14:37:36 +01:00
parent fb76c9d422
commit 1aac6809ea
2 changed files with 37 additions and 0 deletions

View File

@@ -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;
}
}