HHH-3718 rolling back changes
This commit is contained in:
parent
e6df116a49
commit
c83b540218
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue