DATAJPA-775 - JpaPersistenPropertyImpl now rejects Spring Data Commons' @Version.

JpaPersistentPropertyImpl now defensively checks whether Spring Data Commons' @Version annotation is used instead of the JPA one and throws an exception if so as the persistence providers can only deal with the latter and optimistic locking won't work correctly otherwise.

Original pull request: #153.
This commit is contained in:
Greg Turnquist
2015-08-12 23:53:29 -05:00
committed by Oliver Gierke
parent eda57f29f4
commit c9fee0c4f3
2 changed files with 19 additions and 7 deletions

View File

@@ -44,6 +44,7 @@ import org.springframework.data.util.TypeInformation;
* Unit tests for {@link JpaPersistentPropertyImpl}.
*
* @author Oliver Gierke
* @author Greg Turnquist
*/
@RunWith(MockitoJUnitRunner.class)
public class JpaPersistentPropertyImplUnitTests {
@@ -159,10 +160,11 @@ public class JpaPersistentPropertyImplUnitTests {
/**
* @see DATAJPA-605
* @see DATAJPA-775
*/
@Test
@Test(expected = IllegalArgumentException.class)
public void detectsSpringDataVersionAnnotation() {
assertThat(getProperty(SpringDataVersioned.class, "version").isVersionProperty(), is(true));
getProperty(SpringDataVersioned.class, "version");
}
/**
@@ -298,7 +300,7 @@ public class JpaPersistentPropertyImplUnitTests {
static class JpaVersioned {
@Version long version;
@javax.persistence.Version long version;
}
static class SpecializedAssociation {