From 153999d141d5ce07485ac7a2998995b84a4e850a Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Thu, 25 Jul 2013 10:34:21 +0200 Subject: [PATCH] DATAJPA-376 - PersistentProperty now considers JPA @Transient. JpaPersistentPropertyImpl is now considered persistent if it carries a @javax.persistence.Transient annotation. This should allow persistence providers to safely generate additional fields and not cause trouble in the mapping framework this way. --- .../jpa/mapping/JpaPersistentPropertyImpl.java | 10 ++++++++++ .../JpaPersistentPropertyImplUnitTests.java | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java b/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java index a9dc06c89..cf0864bda 100644 --- a/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java +++ b/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java @@ -29,6 +29,7 @@ import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.OneToOne; +import javax.persistence.Transient; import javax.persistence.metamodel.EmbeddableType; import javax.persistence.metamodel.ManagedType; import javax.persistence.metamodel.Metamodel; @@ -132,6 +133,15 @@ class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty entity; @@ -58,9 +58,17 @@ public class JpaPersistentPropertyImplUnitTests { assertThat(property.isAssociation(), is(true)); } + /** + * @see DATAJPA-376 + */ + @Test + public void considersJpaTransientFieldsAsTransient() { + assertThat(entity.getPersistentProperty("transientProp"), is(nullValue())); + } + static class Sample { - @OneToOne - Sample other; + @OneToOne Sample other; + @Transient String transientProp; } }