From c83b540218cbf1619f93d66379609aaa1a5729e9 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Tue, 14 Feb 2012 18:53:28 +0800 Subject: [PATCH] HHH-3718 rolling back changes --- .../property/DirectPropertyAccessor.java | 20 +++---------------- .../property/DirectPropertyAccessorTest.java | 4 +++- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java b/hibernate-core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java index 3ad6528391..67b5670f80 100644 --- a/hibernate-core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java +++ b/hibernate-core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java @@ -25,7 +25,6 @@ package org.hibernate.property; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; -import java.util.Locale; import java.util.Map; import org.hibernate.HibernateException; @@ -45,9 +44,7 @@ public class DirectPropertyAccessor implements PropertyAccessor { private final transient Field field; private final Class clazz; private final String name; - private transient Method method; - private transient boolean methodLookedUp = false; - + DirectGetter(Field field, Class clazz, String name) { this.field = field; this.clazz = clazz; @@ -84,25 +81,14 @@ public class DirectPropertyAccessor implements PropertyAccessor { * {@inheritDoc} */ public Method getMethod() { - if ( !methodLookedUp ) { - //HHH-3718: Return method for identifier access to prevent initialization - try { - String readMethodName = "get" + - name.substring(0, 1).toUpperCase( Locale.ENGLISH ) + - name.substring(1); - method = clazz.getMethod(readMethodName); - } catch (Exception ex) { /* ignore */ } - methodLookedUp = true; - } - return method; + return null; } /** * {@inheritDoc} */ public String getMethodName() { - Method method = getMethod(); - return method == null ? null : method.getName(); + return null; } /** diff --git a/hibernate-core/src/test/java/org/hibernate/property/DirectPropertyAccessorTest.java b/hibernate-core/src/test/java/org/hibernate/property/DirectPropertyAccessorTest.java index f53cb168c2..6773ab2cd3 100644 --- a/hibernate-core/src/test/java/org/hibernate/property/DirectPropertyAccessorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/property/DirectPropertyAccessorTest.java @@ -35,6 +35,7 @@ import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * @author Michael Rudolf @@ -57,7 +58,8 @@ public class DirectPropertyAccessorTest extends BaseCoreFunctionalTestCase { o = ( Order ) s.load( Order.class, 1 ); assertFalse( Hibernate.isInitialized( o ) ); o.getOrderNumber(); - assertFalse( Hibernate.isInitialized( o ) ); + // If you mapped with field access, any method call initializes the proxy + assertTrue( Hibernate.isInitialized( o ) ); s.close(); }