diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java b/spring-data-commons-core/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java index 6afbed9db..dd10a26dc 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2011 by the original author(s). + * Copyright 2011-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.mapping.model; import java.beans.PropertyDescriptor; import java.lang.annotation.Annotation; import java.lang.reflect.Field; -import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -34,7 +32,7 @@ import org.springframework.util.Assert; /** * Simple impementation of {@link PersistentProperty}. * - * @author Jon Brisbin + * @author Jon Brisbin * @author Oliver Gierke */ public abstract class AbstractPersistentProperty

> implements PersistentProperty

{ @@ -127,8 +125,12 @@ public abstract class AbstractPersistentProperty

return null; } + /* + * (non-Javadoc) + * @see org.springframework.data.mapping.PersistentProperty#isTransient() + */ public boolean isTransient() { - return Modifier.isTransient(field.getModifiers()); + return false; } /* diff --git a/spring-data-commons-core/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java b/spring-data-commons-core/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java index bd839efd5..2aef42918 100644 --- a/spring-data-commons-core/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java +++ b/spring-data-commons-core/src/test/java/org/springframework/data/mapping/model/AbstractPersistentPropertyUnitTests.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.data.mapping.model; import static org.hamcrest.Matchers.*; @@ -13,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.springframework.data.mapping.Association; import org.springframework.data.mapping.PersistentEntity; +import org.springframework.data.mapping.PersistentProperty; import org.springframework.data.util.ClassTypeInformation; import org.springframework.data.util.TypeInformation; import org.springframework.util.ReflectionUtils; @@ -94,8 +110,21 @@ public class AbstractPersistentPropertyUnitTests { assertThat(firstProperty.hashCode(), is(secondProperty.hashCode())); } + /** + * @see DATACMNS-180 + */ + @Test + public void doesNotConsiderJavaTransientFieldsTransient() { + + Field transientField = ReflectionUtils.findField(TestClassComplex.class, "transientField"); + + PersistentProperty property = new SamplePersistentProperty(transientField, null, entity, typeHolder); + assertThat(property.isTransient(), is(false)); + } + class Generic { T genericField; + } class FirstConcrete extends Generic { @@ -117,6 +146,7 @@ public class AbstractPersistentPropertyUnitTests { TestClassSet testClassSet; Map map; Collection collection; + transient Object transientField; } class SamplePersistentProperty extends AbstractPersistentProperty {