HHH-7919 : Miscellaneous bugfixes
This commit is contained in:
parent
1b9ca7df6c
commit
77e555ff05
|
@ -29,7 +29,7 @@ import java.io.Serializable;
|
||||||
* A JavaBean bulk accessor, which provides methods capable of getting/setting multiple properties
|
* A JavaBean bulk accessor, which provides methods capable of getting/setting multiple properties
|
||||||
* of a JavaBean at once.
|
* of a JavaBean at once.
|
||||||
*
|
*
|
||||||
* IMPORTANT NOTE!!! Apparently the order of the methods here is important as I think BulkAccessorFactory
|
* IMPORTANT NOTE!!! Apparently the order of the methods here is important as I think {@link BulkAccessorFactory}
|
||||||
* makes use of that information in terms of accessing the constructor. Anyway, when I tried to re-arrange them
|
* makes use of that information in terms of accessing the constructor. Anyway, when I tried to re-arrange them
|
||||||
* the BulkAccessor creation failed and tests started to fail.
|
* the BulkAccessor creation failed and tests started to fail.
|
||||||
*
|
*
|
||||||
|
|
|
@ -72,7 +72,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInIdClass() {
|
public boolean isInIdClass() {
|
||||||
return isInIdClass != null ? isInIdClass : parent != null ? parent.isInIdClass() : false;
|
return isInIdClass != null ? isInIdClass : parent != null && parent.isInIdClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class BackrefPropertyAccessor implements PropertyAccessor {
|
||||||
* we don't know the value of the back reference
|
* we don't know the value of the back reference
|
||||||
*/
|
*/
|
||||||
public static final Serializable UNKNOWN = new Serializable() {
|
public static final Serializable UNKNOWN = new Serializable() {
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "<unknown>";
|
return "<unknown>";
|
||||||
}
|
}
|
||||||
|
@ -78,16 +79,12 @@ public class BackrefPropertyAccessor implements PropertyAccessor {
|
||||||
this.getter = new BackrefGetter();
|
this.getter = new BackrefGetter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Setter getSetter(Class theClass, String propertyName) {
|
public Setter getSetter(Class theClass, String propertyName) {
|
||||||
return setter;
|
return setter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Getter getGetter(Class theClass, String propertyName) {
|
public Getter getGetter(Class theClass, String propertyName) {
|
||||||
return getter;
|
return getter;
|
||||||
}
|
}
|
||||||
|
@ -98,23 +95,17 @@ public class BackrefPropertyAccessor implements PropertyAccessor {
|
||||||
*/
|
*/
|
||||||
public static final class BackrefSetter implements Setter {
|
public static final class BackrefSetter implements Setter {
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||||
// this page intentionally left blank :)
|
// this page intentionally left blank :)
|
||||||
}
|
}
|
||||||
|
@ -127,9 +118,7 @@ public class BackrefPropertyAccessor implements PropertyAccessor {
|
||||||
*/
|
*/
|
||||||
public class BackrefGetter implements Getter {
|
public class BackrefGetter implements Getter {
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
||||||
if ( session == null ) {
|
if ( session == null ) {
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
|
@ -139,37 +128,27 @@ public class BackrefPropertyAccessor implements PropertyAccessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Member getMember() {
|
public Member getMember() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object get(Object target) {
|
public Object get(Object target) {
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Class getReturnType() {
|
public Class getReturnType() {
|
||||||
return Object.class;
|
return Object.class;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.property;
|
package org.hibernate.property;
|
||||||
|
|
||||||
import java.beans.Introspector;
|
import java.beans.Introspector;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Member;
|
import java.lang.reflect.Member;
|
||||||
|
@ -46,33 +47,37 @@ import org.hibernate.internal.util.ReflectHelper;
|
||||||
*/
|
*/
|
||||||
public class BasicPropertyAccessor implements PropertyAccessor {
|
public class BasicPropertyAccessor implements PropertyAccessor {
|
||||||
|
|
||||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, BasicPropertyAccessor.class.getName());
|
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
|
||||||
|
CoreMessageLogger.class,
|
||||||
|
BasicPropertyAccessor.class.getName()
|
||||||
|
);
|
||||||
|
|
||||||
public static final class BasicSetter implements Setter {
|
public static final class BasicSetter implements Setter {
|
||||||
private Class clazz;
|
private final Class clazz;
|
||||||
private final transient Method method;
|
private final transient Method method;
|
||||||
private final String propertyName;
|
private final String propertyName;
|
||||||
|
|
||||||
private BasicSetter(Class clazz, Method method, String propertyName) {
|
private BasicSetter(Class clazz, Method method, String propertyName) {
|
||||||
this.clazz=clazz;
|
this.clazz = clazz;
|
||||||
this.method=method;
|
this.method = method;
|
||||||
this.propertyName=propertyName;
|
this.propertyName = propertyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory)
|
public void set(Object target, Object value, SessionFactoryImplementor factory)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
try {
|
try {
|
||||||
method.invoke( target, value );
|
method.invoke( target, value );
|
||||||
}
|
}
|
||||||
catch (NullPointerException npe) {
|
catch ( NullPointerException npe ) {
|
||||||
if ( value==null && method.getParameterTypes()[0].isPrimitive() ) {
|
if ( value == null && method.getParameterTypes()[0].isPrimitive() ) {
|
||||||
throw new PropertyAccessException(
|
throw new PropertyAccessException(
|
||||||
npe,
|
npe,
|
||||||
"Null value was assigned to a property of primitive type",
|
"Null value was assigned to a property of primitive type",
|
||||||
true,
|
true,
|
||||||
clazz,
|
clazz,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new PropertyAccessException(
|
throw new PropertyAccessException(
|
||||||
|
@ -81,66 +86,71 @@ public class BasicPropertyAccessor implements PropertyAccessor {
|
||||||
true,
|
true,
|
||||||
clazz,
|
clazz,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException ite) {
|
catch ( InvocationTargetException ite ) {
|
||||||
throw new PropertyAccessException(
|
throw new PropertyAccessException(
|
||||||
ite,
|
ite,
|
||||||
"Exception occurred inside",
|
"Exception occurred inside",
|
||||||
true,
|
true,
|
||||||
clazz,
|
clazz,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (IllegalAccessException iae) {
|
catch ( IllegalAccessException iae ) {
|
||||||
throw new PropertyAccessException(
|
throw new PropertyAccessException(
|
||||||
iae,
|
iae,
|
||||||
"IllegalAccessException occurred while calling",
|
"IllegalAccessException occurred while calling",
|
||||||
true,
|
true,
|
||||||
clazz,
|
clazz,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
//cannot occur
|
//cannot occur
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException iae) {
|
catch ( IllegalArgumentException iae ) {
|
||||||
if ( value==null && method.getParameterTypes()[0].isPrimitive() ) {
|
if ( value == null && method.getParameterTypes()[0].isPrimitive() ) {
|
||||||
throw new PropertyAccessException(
|
throw new PropertyAccessException(
|
||||||
iae,
|
iae,
|
||||||
"Null value was assigned to a property of primitive type",
|
"Null value was assigned to a property of primitive type",
|
||||||
true,
|
true,
|
||||||
clazz,
|
clazz,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG.illegalPropertySetterArgument(clazz.getName(), propertyName);
|
LOG.illegalPropertySetterArgument( clazz.getName(), propertyName );
|
||||||
LOG.expectedType(method.getParameterTypes()[0].getName(), value == null ? null : value.getClass().getName());
|
LOG.expectedType(
|
||||||
|
method.getParameterTypes()[0].getName(),
|
||||||
|
value == null ? null : value.getClass().getName()
|
||||||
|
);
|
||||||
throw new PropertyAccessException(
|
throw new PropertyAccessException(
|
||||||
iae,
|
iae,
|
||||||
"IllegalArgumentException occurred while calling",
|
"IllegalArgumentException occurred while calling",
|
||||||
true,
|
true,
|
||||||
clazz,
|
clazz,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return method.getName();
|
return method.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object readResolve() {
|
Object readResolve() {
|
||||||
return createSetter(clazz, propertyName);
|
return createSetter( clazz, propertyName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BasicSetter(" + clazz.getName() + '.' + propertyName + ')';
|
return "BasicSetter(" + clazz.getName() + '.' + propertyName + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,130 +161,122 @@ public class BasicPropertyAccessor implements PropertyAccessor {
|
||||||
private final String propertyName;
|
private final String propertyName;
|
||||||
|
|
||||||
private BasicGetter(Class clazz, Method method, String propertyName) {
|
private BasicGetter(Class clazz, Method method, String propertyName) {
|
||||||
this.clazz=clazz;
|
this.clazz = clazz;
|
||||||
this.method=method;
|
this.method = method;
|
||||||
this.propertyName=propertyName;
|
this.propertyName = propertyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object get(Object target) throws HibernateException {
|
public Object get(Object target) throws HibernateException {
|
||||||
try {
|
try {
|
||||||
return method.invoke( target, (Object[]) null );
|
return method.invoke( target, (Object[]) null );
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException ite) {
|
catch ( InvocationTargetException ite ) {
|
||||||
throw new PropertyAccessException(
|
throw new PropertyAccessException(
|
||||||
ite,
|
ite,
|
||||||
"Exception occurred inside",
|
"Exception occurred inside",
|
||||||
false,
|
false,
|
||||||
clazz,
|
clazz,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (IllegalAccessException iae) {
|
catch ( IllegalAccessException iae ) {
|
||||||
throw new PropertyAccessException(
|
throw new PropertyAccessException(
|
||||||
iae,
|
iae,
|
||||||
"IllegalAccessException occurred while calling",
|
"IllegalAccessException occurred while calling",
|
||||||
false,
|
false,
|
||||||
clazz,
|
clazz,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
//cannot occur
|
//cannot occur
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException iae) {
|
catch ( IllegalArgumentException iae ) {
|
||||||
LOG.illegalPropertyGetterArgument(clazz.getName(), propertyName);
|
LOG.illegalPropertyGetterArgument( clazz.getName(), propertyName );
|
||||||
throw new PropertyAccessException(
|
throw new PropertyAccessException(
|
||||||
iae,
|
iae,
|
||||||
"IllegalArgumentException occurred calling",
|
"IllegalArgumentException occurred calling",
|
||||||
false,
|
false,
|
||||||
clazz,
|
clazz,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
||||||
return get( target );
|
return get( target );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Class getReturnType() {
|
public Class getReturnType() {
|
||||||
return method.getReturnType();
|
return method.getReturnType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Member getMember() {
|
public Member getMember() {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return method.getName();
|
return method.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BasicGetter(" + clazz.getName() + '.' + propertyName + ')';
|
return "BasicGetter(" + clazz.getName() + '.' + propertyName + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
Object readResolve() {
|
Object readResolve() {
|
||||||
return createGetter(clazz, propertyName);
|
return createGetter( clazz, propertyName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Setter getSetter(Class theClass, String propertyName)
|
public Setter getSetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
return createSetter(theClass, propertyName);
|
return createSetter( theClass, propertyName );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Setter createSetter(Class theClass, String propertyName)
|
private static Setter createSetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
BasicSetter result = getSetterOrNull(theClass, propertyName);
|
BasicSetter result = getSetterOrNull( theClass, propertyName );
|
||||||
if (result==null) {
|
if ( result == null ) {
|
||||||
throw new PropertyNotFoundException(
|
throw new PropertyNotFoundException(
|
||||||
"Could not find a setter for property " +
|
"Could not find a setter for property " +
|
||||||
propertyName +
|
propertyName +
|
||||||
" in class " +
|
" in class " +
|
||||||
theClass.getName()
|
theClass.getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BasicSetter getSetterOrNull(Class theClass, String propertyName) {
|
private static BasicSetter getSetterOrNull(Class theClass, String propertyName) {
|
||||||
|
|
||||||
if (theClass==Object.class || theClass==null) return null;
|
if ( theClass == Object.class || theClass == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Method method = setterMethod(theClass, propertyName);
|
Method method = setterMethod( theClass, propertyName );
|
||||||
|
|
||||||
if (method!=null) {
|
if ( method != null ) {
|
||||||
if ( !ReflectHelper.isPublic(theClass, method) ) method.setAccessible(true);
|
if ( !ReflectHelper.isPublic( theClass, method ) ) {
|
||||||
return new BasicSetter(theClass, method, propertyName);
|
method.setAccessible( true );
|
||||||
|
}
|
||||||
|
return new BasicSetter( theClass, method, propertyName );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BasicSetter setter = getSetterOrNull( theClass.getSuperclass(), propertyName );
|
BasicSetter setter = getSetterOrNull( theClass.getSuperclass(), propertyName );
|
||||||
if (setter==null) {
|
if ( setter == null ) {
|
||||||
Class[] interfaces = theClass.getInterfaces();
|
Class[] interfaces = theClass.getInterfaces();
|
||||||
for ( int i=0; setter==null && i<interfaces.length; i++ ) {
|
for ( int i = 0; setter == null && i < interfaces.length; i++ ) {
|
||||||
setter=getSetterOrNull( interfaces[i], propertyName );
|
setter = getSetterOrNull( interfaces[i], propertyName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return setter;
|
return setter;
|
||||||
|
@ -284,8 +286,8 @@ public class BasicPropertyAccessor implements PropertyAccessor {
|
||||||
|
|
||||||
private static Method setterMethod(Class theClass, String propertyName) {
|
private static Method setterMethod(Class theClass, String propertyName) {
|
||||||
|
|
||||||
BasicGetter getter = getGetterOrNull(theClass, propertyName);
|
BasicGetter getter = getGetterOrNull( theClass, propertyName );
|
||||||
Class returnType = (getter==null) ? null : getter.getReturnType();
|
Class returnType = ( getter == null ) ? null : getter.getReturnType();
|
||||||
|
|
||||||
Method[] methods = theClass.getDeclaredMethods();
|
Method[] methods = theClass.getDeclaredMethods();
|
||||||
Method potentialSetter = null;
|
Method potentialSetter = null;
|
||||||
|
@ -306,42 +308,43 @@ public class BasicPropertyAccessor implements PropertyAccessor {
|
||||||
return potentialSetter;
|
return potentialSetter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException {
|
public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException {
|
||||||
return createGetter(theClass, propertyName);
|
return createGetter( theClass, propertyName );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Getter createGetter(Class theClass, String propertyName) throws PropertyNotFoundException {
|
public static Getter createGetter(Class theClass, String propertyName) throws PropertyNotFoundException {
|
||||||
BasicGetter result = getGetterOrNull(theClass, propertyName);
|
BasicGetter result = getGetterOrNull( theClass, propertyName );
|
||||||
if (result==null) {
|
if ( result == null ) {
|
||||||
throw new PropertyNotFoundException(
|
throw new PropertyNotFoundException(
|
||||||
"Could not find a getter for " +
|
"Could not find a getter for " +
|
||||||
propertyName +
|
propertyName +
|
||||||
" in class " +
|
" in class " +
|
||||||
theClass.getName()
|
theClass.getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BasicGetter getGetterOrNull(Class theClass, String propertyName) {
|
private static BasicGetter getGetterOrNull(Class theClass, String propertyName) {
|
||||||
if (theClass==Object.class || theClass==null) {
|
if ( theClass == Object.class || theClass == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Method method = getterMethod(theClass, propertyName);
|
Method method = getterMethod( theClass, propertyName );
|
||||||
|
|
||||||
if (method!=null) {
|
if ( method != null ) {
|
||||||
if ( !ReflectHelper.isPublic( theClass, method ) ) {
|
if ( !ReflectHelper.isPublic( theClass, method ) ) {
|
||||||
method.setAccessible(true);
|
method.setAccessible( true );
|
||||||
}
|
}
|
||||||
return new BasicGetter(theClass, method, propertyName);
|
return new BasicGetter( theClass, method, propertyName );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BasicGetter getter = getGetterOrNull( theClass.getSuperclass(), propertyName );
|
BasicGetter getter = getGetterOrNull( theClass.getSuperclass(), propertyName );
|
||||||
if (getter==null) {
|
if ( getter == null ) {
|
||||||
Class[] interfaces = theClass.getInterfaces();
|
Class[] interfaces = theClass.getInterfaces();
|
||||||
for ( int i=0; getter==null && i<interfaces.length; i++ ) {
|
for ( int i = 0; getter == null && i < interfaces.length; i++ ) {
|
||||||
getter=getGetterOrNull( interfaces[i], propertyName );
|
getter = getGetterOrNull( interfaces[i], propertyName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getter;
|
return getter;
|
||||||
|
|
|
@ -35,32 +35,28 @@ public class ChainedPropertyAccessor implements PropertyAccessor {
|
||||||
public ChainedPropertyAccessor(PropertyAccessor[] chain) {
|
public ChainedPropertyAccessor(PropertyAccessor[] chain) {
|
||||||
this.chain = chain;
|
this.chain = chain;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Getter getGetter(Class theClass, String propertyName)
|
public Getter getGetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
Getter result = null;
|
for ( PropertyAccessor candidate : chain ) {
|
||||||
for (int i = 0; i < chain.length; i++) {
|
|
||||||
PropertyAccessor candidate = chain[i];
|
|
||||||
try {
|
try {
|
||||||
result = candidate.getGetter(theClass, propertyName);
|
return candidate.getGetter( theClass, propertyName );
|
||||||
return result;
|
}
|
||||||
} catch (PropertyNotFoundException pnfe) {
|
catch ( PropertyNotFoundException pnfe ) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new PropertyNotFoundException("Could not find getter for " + propertyName + " on " + theClass);
|
throw new PropertyNotFoundException("Could not find getter for " + propertyName + " on " + theClass);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Setter getSetter(Class theClass, String propertyName)
|
public Setter getSetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
Setter result = null;
|
for ( PropertyAccessor candidate : chain ) {
|
||||||
for (int i = 0; i < chain.length; i++) {
|
|
||||||
PropertyAccessor candidate = chain[i];
|
|
||||||
try {
|
try {
|
||||||
result = candidate.getSetter(theClass, propertyName);
|
return candidate.getSetter( theClass, propertyName );
|
||||||
return result;
|
}
|
||||||
} catch (PropertyNotFoundException pnfe) {
|
catch ( PropertyNotFoundException pnfe ) {
|
||||||
//
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new PropertyNotFoundException("Could not find setter for " + propertyName + " on " + theClass);
|
throw new PropertyNotFoundException("Could not find setter for " + propertyName + " on " + theClass);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.property;
|
package org.hibernate.property;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Member;
|
import java.lang.reflect.Member;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -36,6 +37,7 @@ import org.hibernate.internal.util.ReflectHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accesses fields directly.
|
* Accesses fields directly.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class DirectPropertyAccessor implements PropertyAccessor {
|
public class DirectPropertyAccessor implements PropertyAccessor {
|
||||||
|
@ -51,57 +53,46 @@ public class DirectPropertyAccessor implements PropertyAccessor {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object get(Object target) throws HibernateException {
|
public Object get(Object target) throws HibernateException {
|
||||||
try {
|
try {
|
||||||
return field.get(target);
|
return field.get( target );
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch ( Exception e ) {
|
||||||
throw new PropertyAccessException(e, "could not get a field value by reflection", false, clazz, name);
|
throw new PropertyAccessException( e, "could not get a field value by reflection", false, clazz, name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
||||||
return get( target );
|
return get( target );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Member getMember() {
|
public Member getMember() {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Class getReturnType() {
|
public Class getReturnType() {
|
||||||
return field.getType();
|
return field.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object readResolve() {
|
Object readResolve() {
|
||||||
return new DirectGetter( getField(clazz, name), clazz, name );
|
return new DirectGetter( getField( clazz, name ), clazz, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DirectGetter(" + clazz.getName() + '.' + name + ')';
|
return "DirectGetter(" + clazz.getName() + '.' + name + ')';
|
||||||
}
|
}
|
||||||
|
@ -111,95 +102,90 @@ public class DirectPropertyAccessor implements PropertyAccessor {
|
||||||
private final transient Field field;
|
private final transient Field field;
|
||||||
private final Class clazz;
|
private final Class clazz;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
DirectSetter(Field field, Class clazz, String name) {
|
DirectSetter(Field field, Class clazz, String name) {
|
||||||
this.field = field;
|
this.field = field;
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException {
|
public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException {
|
||||||
try {
|
try {
|
||||||
field.set(target, value);
|
field.set( target, value );
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch ( Exception e ) {
|
||||||
if(value == null && field.getType().isPrimitive()) {
|
String errorMsg = ( value == null && field.getType().isPrimitive() ) ?
|
||||||
throw new PropertyAccessException(
|
"Null value was assigned to a property of primitive type"
|
||||||
e,
|
: "could not set a field value by reflection";
|
||||||
"Null value was assigned to a property of primitive type",
|
throw new PropertyAccessException( e, errorMsg, true, clazz, name );
|
||||||
true,
|
|
||||||
clazz,
|
|
||||||
name
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw new PropertyAccessException(e, "could not set a field value by reflection", true, clazz, name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DirectSetter(" + clazz.getName() + '.' + name + ')';
|
return "DirectSetter(" + clazz.getName() + '.' + name + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
Object readResolve() {
|
Object readResolve() {
|
||||||
return new DirectSetter( getField(clazz, name), clazz, name );
|
return new DirectSetter( getField( clazz, name ), clazz, name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Field getField(Class clazz, String name) throws PropertyNotFoundException {
|
private static Field getField(Class clazz, String name) throws PropertyNotFoundException {
|
||||||
if ( clazz==null || clazz==Object.class ) {
|
if ( clazz == null || clazz == Object.class ) {
|
||||||
throw new PropertyNotFoundException("field not found: " + name);
|
throw new PropertyNotFoundException( "field not found: " + name );
|
||||||
}
|
}
|
||||||
Field field;
|
Field field;
|
||||||
try {
|
try {
|
||||||
field = clazz.getDeclaredField(name);
|
field = clazz.getDeclaredField( name );
|
||||||
}
|
}
|
||||||
catch (NoSuchFieldException nsfe) {
|
catch ( NoSuchFieldException nsfe ) {
|
||||||
field = getField( clazz, clazz.getSuperclass(), name );
|
field = getField( clazz, clazz.getSuperclass(), name );
|
||||||
}
|
}
|
||||||
if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);
|
if ( !ReflectHelper.isPublic( clazz, field ) ) {
|
||||||
|
field.setAccessible( true );
|
||||||
|
}
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Field getField(Class root, Class clazz, String name) throws PropertyNotFoundException {
|
private static Field getField(Class root, Class clazz, String name) throws PropertyNotFoundException {
|
||||||
if ( clazz==null || clazz==Object.class ) {
|
if ( clazz == null || clazz == Object.class ) {
|
||||||
throw new PropertyNotFoundException("field [" + name + "] not found on " + root.getName());
|
throw new PropertyNotFoundException( "field [" + name + "] not found on " + root.getName() );
|
||||||
}
|
}
|
||||||
Field field;
|
Field field;
|
||||||
try {
|
try {
|
||||||
field = clazz.getDeclaredField(name);
|
field = clazz.getDeclaredField( name );
|
||||||
}
|
}
|
||||||
catch (NoSuchFieldException nsfe) {
|
catch ( NoSuchFieldException nsfe ) {
|
||||||
field = getField( root, clazz.getSuperclass(), name );
|
field = getField( root, clazz.getSuperclass(), name );
|
||||||
}
|
}
|
||||||
if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);
|
if ( !ReflectHelper.isPublic( clazz, field ) ) {
|
||||||
|
field.setAccessible( true );
|
||||||
|
}
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Getter getGetter(Class theClass, String propertyName)
|
public Getter getGetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
return new DirectGetter( getField(theClass, propertyName), theClass, propertyName );
|
return new DirectGetter( getField( theClass, propertyName ), theClass, propertyName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Setter getSetter(Class theClass, String propertyName)
|
public Setter getSetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
return new DirectSetter( getField(theClass, propertyName), theClass, propertyName );
|
return new DirectSetter( getField( theClass, propertyName ), theClass, propertyName );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,49 +42,37 @@ public class EmbeddedPropertyAccessor implements PropertyAccessor {
|
||||||
EmbeddedGetter(Class clazz) {
|
EmbeddedGetter(Class clazz) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object get(Object target) throws HibernateException {
|
public Object get(Object target) throws HibernateException {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
||||||
return get( target );
|
return get( target );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Member getMember() {
|
public Member getMember() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Class getReturnType() {
|
public Class getReturnType() {
|
||||||
return clazz;
|
return clazz;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "EmbeddedGetter(" + clazz.getName() + ')';
|
return "EmbeddedGetter(" + clazz.getName() + ')';
|
||||||
}
|
}
|
||||||
|
@ -96,43 +84,37 @@ public class EmbeddedPropertyAccessor implements PropertyAccessor {
|
||||||
EmbeddedSetter(Class clazz) {
|
EmbeddedSetter(Class clazz) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "EmbeddedSetter(" + clazz.getName() + ')';
|
return "EmbeddedSetter(" + clazz.getName() + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Getter getGetter(Class theClass, String propertyName)
|
public Getter getGetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
return new EmbeddedGetter(theClass);
|
return new EmbeddedGetter( theClass );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Setter getSetter(Class theClass, String propertyName)
|
public Setter getSetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
return new EmbeddedSetter(theClass);
|
return new EmbeddedSetter( theClass );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,11 @@ public class IndexPropertyAccessor implements PropertyAccessor {
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Setter getSetter(Class theClass, String propertyName) {
|
public Setter getSetter(Class theClass, String propertyName) {
|
||||||
return new IndexSetter();
|
return new IndexSetter();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Getter getGetter(Class theClass, String propertyName) {
|
public Getter getGetter(Class theClass, String propertyName) {
|
||||||
return new IndexGetter();
|
return new IndexGetter();
|
||||||
}
|
}
|
||||||
|
@ -63,23 +64,17 @@ public class IndexPropertyAccessor implements PropertyAccessor {
|
||||||
* The Setter implementation for index backrefs.
|
* The Setter implementation for index backrefs.
|
||||||
*/
|
*/
|
||||||
public static final class IndexSetter implements Setter {
|
public static final class IndexSetter implements Setter {
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||||
// do nothing...
|
// do nothing...
|
||||||
}
|
}
|
||||||
|
@ -91,47 +86,38 @@ public class IndexPropertyAccessor implements PropertyAccessor {
|
||||||
* The Getter implementation for index backrefs.
|
* The Getter implementation for index backrefs.
|
||||||
*/
|
*/
|
||||||
public class IndexGetter implements Getter {
|
public class IndexGetter implements Getter {
|
||||||
|
@Override
|
||||||
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) throws HibernateException {
|
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) throws HibernateException {
|
||||||
if (session==null) {
|
if ( session == null ) {
|
||||||
return BackrefPropertyAccessor.UNKNOWN;
|
return BackrefPropertyAccessor.UNKNOWN;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return session.getPersistenceContext()
|
return session.getPersistenceContext()
|
||||||
.getIndexInOwner(entityName, propertyName, target, mergeMap);
|
.getIndexInOwner( entityName, propertyName, target, mergeMap );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object get(Object target) {
|
public Object get(Object target) {
|
||||||
return BackrefPropertyAccessor.UNKNOWN;
|
return BackrefPropertyAccessor.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Member getMember() {
|
public Member getMember() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Class getReturnType() {
|
public Class getReturnType() {
|
||||||
return Object.class;
|
return Object.class;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,98 +35,77 @@ import org.hibernate.engine.spi.SessionImplementor;
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class MapAccessor implements PropertyAccessor {
|
public class MapAccessor implements PropertyAccessor {
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Getter getGetter(Class theClass, String propertyName)
|
public Getter getGetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
return new MapGetter(propertyName);
|
return new MapGetter(propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Setter getSetter(Class theClass, String propertyName)
|
public Setter getSetter(Class theClass, String propertyName)
|
||||||
throws PropertyNotFoundException {
|
throws PropertyNotFoundException {
|
||||||
return new MapSetter(propertyName);
|
return new MapSetter(propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static final class MapSetter implements Setter {
|
public static final class MapSetter implements Setter {
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
MapSetter(String name) {
|
MapSetter(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory)
|
public void set(Object target, Object value, SessionFactoryImplementor factory)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
( (Map) target ).put(name, value);
|
( (Map) target ).put( name, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class MapGetter implements Getter {
|
public static final class MapGetter implements Getter {
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
MapGetter(String name) {
|
MapGetter(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Member getMember() {
|
public Member getMember() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object get(Object target) throws HibernateException {
|
public Object get(Object target) throws HibernateException {
|
||||||
return ( (Map) target ).get(name);
|
return ( (Map) target ).get( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
|
||||||
return get( target );
|
return get( target );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Class getReturnType() {
|
public Class getReturnType() {
|
||||||
return Object.class;
|
return Object.class;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,16 +37,12 @@ import org.hibernate.engine.spi.SessionImplementor;
|
||||||
* @author Michael Bartmann
|
* @author Michael Bartmann
|
||||||
*/
|
*/
|
||||||
public class NoopAccessor implements PropertyAccessor {
|
public class NoopAccessor implements PropertyAccessor {
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Getter getGetter(Class arg0, String arg1) throws PropertyNotFoundException {
|
public Getter getGetter(Class arg0, String arg1) throws PropertyNotFoundException {
|
||||||
return new NoopGetter();
|
return new NoopGetter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Setter getSetter(Class arg0, String arg1) throws PropertyNotFoundException {
|
public Setter getSetter(Class arg0, String arg1) throws PropertyNotFoundException {
|
||||||
return new NoopSetter();
|
return new NoopSetter();
|
||||||
}
|
}
|
||||||
|
@ -56,46 +52,35 @@ public class NoopAccessor implements PropertyAccessor {
|
||||||
*/
|
*/
|
||||||
private static class NoopGetter implements Getter {
|
private static class NoopGetter implements Getter {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
* <p/>
|
|
||||||
* Here we always return <tt>null</tt>
|
* Here we always return <tt>null</tt>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object get(Object target) throws HibernateException {
|
public Object get(Object target) throws HibernateException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object getForInsert(Object target, Map map, SessionImplementor arg1)
|
public Object getForInsert(Object target, Map map, SessionImplementor arg1)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Class getReturnType() {
|
public Class getReturnType() {
|
||||||
return Object.class;
|
return Object.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Member getMember() {
|
public Member getMember() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -105,23 +90,17 @@ public class NoopAccessor implements PropertyAccessor {
|
||||||
* A Setter which will just do nothing.
|
* A Setter which will just do nothing.
|
||||||
*/
|
*/
|
||||||
private static class NoopSetter implements Setter {
|
private static class NoopSetter implements Setter {
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor arg2) {
|
public void set(Object target, Object value, SessionFactoryImplementor arg2) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package org.hibernate.test.instrument.cases;
|
package org.hibernate.test.instrument.cases;
|
||||||
|
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.boot.registry.BootstrapServiceRegistry;
|
||||||
|
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.metamodel.MetadataSources;
|
import org.hibernate.metamodel.MetadataSources;
|
||||||
|
@ -17,8 +20,22 @@ public abstract class AbstractExecutable implements Executable {
|
||||||
private SessionFactory factory;
|
private SessionFactory factory;
|
||||||
@Override
|
@Override
|
||||||
public final void prepare() {
|
public final void prepare() {
|
||||||
|
prepare( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void prepare(ClassLoader instrumentedClassLoader) {
|
||||||
Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
BootstrapServiceRegistryBuilder bootstrapServiceRegistryBuilder = new BootstrapServiceRegistryBuilder();
|
||||||
|
if ( instrumentedClassLoader != null ) // old metamodel case
|
||||||
|
{
|
||||||
|
bootstrapServiceRegistryBuilder.with( instrumentedClassLoader );
|
||||||
|
}
|
||||||
|
BootstrapServiceRegistry bootstrapServiceRegistry = bootstrapServiceRegistryBuilder.build();
|
||||||
|
|
||||||
|
StandardServiceRegistryBuilder standardServiceRegistryBuilder = new StandardServiceRegistryBuilder(bootstrapServiceRegistry);
|
||||||
|
serviceRegistry = standardServiceRegistryBuilder.applySettings( cfg.getProperties() ).build();
|
||||||
|
|
||||||
String[] resources = getResources();
|
String[] resources = getResources();
|
||||||
if( BaseUnitTestCase.isMetadataUsed()){
|
if( BaseUnitTestCase.isMetadataUsed()){
|
||||||
MetadataSources metadataSources = new MetadataSources( serviceRegistry );
|
MetadataSources metadataSources = new MetadataSources( serviceRegistry );
|
||||||
|
@ -34,7 +51,8 @@ public abstract class AbstractExecutable implements Executable {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
|
@Override
|
||||||
public final void complete() {
|
public final void complete() {
|
||||||
try {
|
try {
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
package org.hibernate.test.instrument.cases;
|
package org.hibernate.test.instrument.cases;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface Executable {
|
public interface Executable {
|
||||||
public void prepare();
|
void prepare();
|
||||||
public void execute() throws Exception;
|
|
||||||
public void complete();
|
/**
|
||||||
|
* The reason that we need this method in the metamodel branch is because in this branch,
|
||||||
|
* we use {@link org.hibernate.boot.registry.classloading.spi.ClassLoaderService} to load entity classes
|
||||||
|
* (well, every classes), and by default, this service uses default hibernate classloader first, then
|
||||||
|
* it will bypass the instrument classloader, so here we have to explicitly provide this classloader to the
|
||||||
|
* {@link org.hibernate.boot.registry.classloading.spi.ClassLoaderService}.
|
||||||
|
*
|
||||||
|
* @param instrumentedClassLoader
|
||||||
|
*/
|
||||||
|
void prepare(ClassLoader instrumentedClassLoader);
|
||||||
|
void execute() throws Exception;
|
||||||
|
void complete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package org.hibernate.test.instrument.cases;
|
package org.hibernate.test.instrument.cases;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.hibernate.CacheMode;
|
import org.hibernate.CacheMode;
|
||||||
|
@ -15,6 +16,7 @@ import org.hibernate.test.instrument.domain.Owner;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class TestLazyExecutable extends AbstractExecutable {
|
public class TestLazyExecutable extends AbstractExecutable {
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
// The following block is repeated 100 times to reproduce HHH-2627.
|
// The following block is repeated 100 times to reproduce HHH-2627.
|
||||||
// Without the fix, Oracle will run out of cursors using 10g with
|
// Without the fix, Oracle will run out of cursors using 10g with
|
||||||
|
@ -22,183 +24,183 @@ public class TestLazyExecutable extends AbstractExecutable {
|
||||||
// The number of loops may need to be adjusted depending on the how
|
// The number of loops may need to be adjusted depending on the how
|
||||||
// Oracle is configured.
|
// Oracle is configured.
|
||||||
// Note: The block is not indented to avoid a lot of irrelevant differences.
|
// Note: The block is not indented to avoid a lot of irrelevant differences.
|
||||||
for ( int i=0; i<100; i++ ) {
|
for ( int i = 0; i < 100; i++ ) {
|
||||||
|
|
||||||
SessionFactory factory = getFactory();
|
SessionFactory factory = getFactory();
|
||||||
Session s = factory.openSession();
|
Session s = factory.openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
Owner o = new Owner();
|
Owner o = new Owner();
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
Folder fol = new Folder();
|
Folder fol = new Folder();
|
||||||
o.setName("gavin");
|
o.setName( "gavin" );
|
||||||
doc.setName("Hibernate in Action");
|
doc.setName( "Hibernate in Action" );
|
||||||
doc.setSummary("blah");
|
doc.setSummary( "blah" );
|
||||||
doc.updateText("blah blah");
|
doc.updateText( "blah blah" );
|
||||||
fol.setName("books");
|
fol.setName( "books" );
|
||||||
doc.setOwner(o);
|
doc.setOwner( o );
|
||||||
doc.setFolder(fol);
|
doc.setFolder( fol );
|
||||||
fol.getDocuments().add(doc);
|
fol.getDocuments().add( doc );
|
||||||
s.save(o);
|
s.save( o );
|
||||||
s.save(fol);
|
s.save( fol );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = ( Document ) s.get( Document.class, doc.getId() );
|
doc = (Document) s.get( Document.class, doc.getId() );
|
||||||
TestCase.assertTrue( Hibernate.isPropertyInitialized(doc, "weirdProperty"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "weirdProperty" ) );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "name"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "name" ) );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "upperCaseName"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "folder"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "folder" ) );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "owner"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "owner" ) );
|
||||||
doc.getUpperCaseName(); // should force initialization
|
doc.getUpperCaseName(); // should force initialization
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "weirdProperty"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "weirdProperty" ) );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "upperCaseName"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "folder"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "folder" ) );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "owner"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "owner" ) );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
doc.getName();
|
doc.getName();
|
||||||
TestCase.assertEquals( doc.getText(), "blah blah" );
|
TestCase.assertEquals( doc.getText(), "blah blah" );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
doc.getName();
|
doc.getName();
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "summary"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "summary" ) );
|
||||||
TestCase.assertEquals( doc.getText(), "blah blah" );
|
TestCase.assertEquals( doc.getText(), "blah blah" );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "summary"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
doc.setName("HiA");
|
doc.setName( "HiA" );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
TestCase.assertEquals( doc.getName(), "HiA" );
|
TestCase.assertEquals( doc.getName(), "HiA" );
|
||||||
TestCase.assertEquals( doc.getText(), "blah blah" );
|
TestCase.assertEquals( doc.getText(), "blah blah" );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
doc.getText();
|
doc.getText();
|
||||||
doc.setName("HiA second edition");
|
doc.setName( "HiA second edition" );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "weirdProperty"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "weirdProperty" ) );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "name"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "name" ) );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "upperCaseName"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "owner"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "owner" ) );
|
||||||
TestCase.assertEquals( doc.getName(), "HiA second edition" );
|
TestCase.assertEquals( doc.getName(), "HiA second edition" );
|
||||||
TestCase.assertEquals( doc.getText(), "blah blah" );
|
TestCase.assertEquals( doc.getText(), "blah blah" );
|
||||||
TestCase.assertEquals( doc.getUpperCaseName(), "HIA SECOND EDITION" );
|
TestCase.assertEquals( doc.getUpperCaseName(), "HIA SECOND EDITION" );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "weirdProperty"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "weirdProperty" ) );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "upperCaseName"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
s.lock(doc, LockMode.NONE);
|
s.lock( doc, LockMode.NONE );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
TestCase.assertEquals( doc.getText(), "blah blah" );
|
TestCase.assertEquals( doc.getText(), "blah blah" );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
doc.setName("HiA2");
|
doc.setName( "HiA2" );
|
||||||
|
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
s.saveOrUpdate(doc);
|
s.saveOrUpdate( doc );
|
||||||
s.flush();
|
s.flush();
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
TestCase.assertEquals( doc.getText(), "blah blah" );
|
TestCase.assertEquals( doc.getText(), "blah blah" );
|
||||||
TestCase.assertTrue(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertTrue( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
doc.updateText("blah blah blah blah");
|
doc.updateText( "blah blah blah blah" );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = ( Document ) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
TestCase.assertEquals( doc.getName(), "HiA2" );
|
TestCase.assertEquals( doc.getName(), "HiA2" );
|
||||||
TestCase.assertEquals( doc.getText(), "blah blah blah blah" );
|
TestCase.assertEquals( doc.getText(), "blah blah blah blah" );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.load( Document.class, doc.getId() );
|
doc = (Document) s.load( Document.class, doc.getId() );
|
||||||
doc.getName();
|
doc.getName();
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "text"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "text" ) );
|
||||||
TestCase.assertFalse(Hibernate.isPropertyInitialized(doc, "summary"));
|
TestCase.assertFalse( Hibernate.isPropertyInitialized( doc, "summary" ) );
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = factory.openSession();
|
s = factory.openSession();
|
||||||
s.setCacheMode( CacheMode.IGNORE );
|
s.setCacheMode( CacheMode.IGNORE );
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
doc = (Document) s.createQuery("from Document").uniqueResult();
|
doc = (Document) s.createQuery( "from Document" ).uniqueResult();
|
||||||
//s.delete(doc);
|
//s.delete(doc);
|
||||||
s.delete( doc.getFolder() );
|
s.delete( doc.getFolder() );
|
||||||
s.delete( doc.getOwner() );
|
s.delete( doc.getOwner() );
|
||||||
s.flush();
|
s.flush();
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,11 @@ import org.hibernate.test.instrument.domain.Problematic;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class TestLazyPropertyCustomTypeExecutable extends AbstractExecutable {
|
public class TestLazyPropertyCustomTypeExecutable extends AbstractExecutable {
|
||||||
|
@Override
|
||||||
protected String[] getResources() {
|
protected String[] getResources() {
|
||||||
return new String[] { "org/hibernate/test/instrument/domain/Problematic.hbm.xml" };
|
return new String[] { "org/hibernate/test/instrument/domain/Problematic.hbm.xml" };
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() throws Exception {
|
||||||
Session s = getFactory().openSession();
|
Session s = getFactory().openSession();
|
||||||
Problematic p = new Problematic();
|
Problematic p = new Problematic();
|
||||||
|
@ -76,7 +76,7 @@ public class TestLazyPropertyCustomTypeExecutable extends AbstractExecutable {
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
protected void cleanup() {
|
protected void cleanup() {
|
||||||
Session s = getFactory().openSession();
|
Session s = getFactory().openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.hibernate.bytecode.buildtime.spi.FieldFilter;
|
||||||
import org.hibernate.bytecode.spi.BytecodeProvider;
|
import org.hibernate.bytecode.spi.BytecodeProvider;
|
||||||
import org.hibernate.bytecode.spi.InstrumentedClassLoader;
|
import org.hibernate.bytecode.spi.InstrumentedClassLoader;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.hibernate.testing.junit4.ClassLoadingIsolater;
|
import org.hibernate.testing.junit4.ClassLoadingIsolater;
|
||||||
|
@ -136,8 +137,10 @@ public abstract class AbstractTransformingClassLoaderInstrumentTestCase extends
|
||||||
|
|
||||||
// reflection code to ensure isolation into the created classloader ~~~~~~~
|
// reflection code to ensure isolation into the created classloader ~~~~~~~
|
||||||
|
|
||||||
private static final Class[] SIG = new Class[] {};
|
private static final Class[] SIG_METAMODEL = new Class[]{ClassLoader.class};
|
||||||
private static final Object[] ARGS = new Object[] {};
|
private static final String PREPARE = "prepare";
|
||||||
|
private static final String EXECUTE = "execute";
|
||||||
|
private static final String COMPLETE = "complete";
|
||||||
|
|
||||||
public void executeExecutable(String name) {
|
public void executeExecutable(String name) {
|
||||||
Class execClass = null;
|
Class execClass = null;
|
||||||
|
@ -150,8 +153,14 @@ public abstract class AbstractTransformingClassLoaderInstrumentTestCase extends
|
||||||
throw new HibernateException( "could not load executable", t );
|
throw new HibernateException( "could not load executable", t );
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
execClass.getMethod( "prepare", SIG ).invoke( executable, ARGS );
|
if ( BaseUnitTestCase.isMetadataUsed() ) {
|
||||||
execClass.getMethod( "execute", SIG ).invoke( executable, ARGS );
|
execClass.getMethod( PREPARE, SIG_METAMODEL )
|
||||||
|
.invoke( executable, new ClassLoader[] { Thread.currentThread().getContextClassLoader() } );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
execClass.getMethod( PREPARE, ReflectHelper.NO_PARAM_SIGNATURE ).invoke( executable, ReflectHelper.NO_PARAMS );
|
||||||
|
}
|
||||||
|
execClass.getMethod( EXECUTE, ReflectHelper.NO_PARAM_SIGNATURE ).invoke( executable, ReflectHelper.NO_PARAMS );
|
||||||
}
|
}
|
||||||
catch ( NoSuchMethodException e ) {
|
catch ( NoSuchMethodException e ) {
|
||||||
throw new HibernateException( "could not exeucte executable", e );
|
throw new HibernateException( "could not exeucte executable", e );
|
||||||
|
@ -164,7 +173,7 @@ public abstract class AbstractTransformingClassLoaderInstrumentTestCase extends
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
execClass.getMethod( "complete", SIG ).invoke( executable, ARGS );
|
execClass.getMethod( COMPLETE, ReflectHelper.NO_PARAM_SIGNATURE ).invoke( executable, ReflectHelper.NO_PARAMS );
|
||||||
}
|
}
|
||||||
catch ( Throwable ignore ) {
|
catch ( Throwable ignore ) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,47 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.instrument.runtime;
|
package org.hibernate.test.instrument.runtime;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl;
|
import org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl;
|
||||||
import org.hibernate.bytecode.spi.BytecodeProvider;
|
import org.hibernate.bytecode.spi.BytecodeProvider;
|
||||||
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class JavassistInstrumentationTest extends AbstractTransformingClassLoaderInstrumentTestCase {
|
public class JavassistInstrumentationTest extends AbstractTransformingClassLoaderInstrumentTestCase {
|
||||||
|
@Override
|
||||||
protected BytecodeProvider buildBytecodeProvider() {
|
protected BytecodeProvider buildBytecodeProvider() {
|
||||||
return new BytecodeProviderImpl();
|
return new BytecodeProviderImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FailureExpectedWithNewMetamodel
|
||||||
|
@Test
|
||||||
|
@Override
|
||||||
|
public void testLazy() {
|
||||||
|
super.testLazy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FailureExpectedWithNewMetamodel
|
||||||
|
@Test
|
||||||
|
@Override
|
||||||
|
public void testLazyManyToOne() {
|
||||||
|
super.testLazyManyToOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FailureExpectedWithNewMetamodel
|
||||||
|
@Test
|
||||||
|
@Override
|
||||||
|
public void testSharedPKOneToOne() {
|
||||||
|
super.testSharedPKOneToOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FailureExpectedWithNewMetamodel
|
||||||
|
@Test
|
||||||
|
@Override
|
||||||
|
public void testManyToOneProxy() {
|
||||||
|
super.testManyToOneProxy();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,12 @@ import javax.persistence.EntityManagerFactory;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public class SecondMetadataTest extends BaseEntityManagerFunctionalTestCase {
|
public class SecondMetadataTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testBaseOfService() throws Exception {
|
public void testBaseOfService() throws Exception {
|
||||||
|
|
|
@ -508,7 +508,6 @@ public class InfinispanRegionFactory extends AbstractRegionFactory {
|
||||||
TypeOverrides regionOverride = typeOverrides.get(regionName);
|
TypeOverrides regionOverride = typeOverrides.get(regionName);
|
||||||
if (!definedConfigurations.contains(regionName)) {
|
if (!definedConfigurations.contains(regionName)) {
|
||||||
String templateCacheName;
|
String templateCacheName;
|
||||||
Configuration regionCacheCfg;
|
|
||||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||||
if (regionOverride != null) {
|
if (regionOverride != null) {
|
||||||
if (log.isDebugEnabled()) log.debug("Cache region specific configuration exists: " + regionOverride);
|
if (log.isDebugEnabled()) log.debug("Cache region specific configuration exists: " + regionOverride);
|
||||||
|
@ -556,8 +555,7 @@ public class InfinispanRegionFactory extends AbstractRegionFactory {
|
||||||
.getGlobalComponentRegistry();
|
.getGlobalComponentRegistry();
|
||||||
|
|
||||||
Map<Byte, ModuleCommandFactory> factories =
|
Map<Byte, ModuleCommandFactory> factories =
|
||||||
(Map<Byte, ModuleCommandFactory>) globalCr
|
globalCr.getComponent("org.infinispan.modules.command.factories");
|
||||||
.getComponent("org.infinispan.modules.command.factories");
|
|
||||||
|
|
||||||
for (ModuleCommandFactory factory : factories.values()) {
|
for (ModuleCommandFactory factory : factories.values()) {
|
||||||
if (factory instanceof CacheCommandFactory)
|
if (factory instanceof CacheCommandFactory)
|
||||||
|
|
|
@ -71,15 +71,17 @@ public class ClusterAwareRegionFactory extends AbstractRegionFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearCacheManagers() {
|
public static void clearCacheManagers() {
|
||||||
for ( EmbeddedCacheManager manager : cacheManagers.values() ) {
|
try {
|
||||||
try {
|
for ( EmbeddedCacheManager manager : cacheManagers.values() ) {
|
||||||
manager.stop();
|
manager.stop();
|
||||||
}
|
}
|
||||||
catch ( Exception e ) {
|
|
||||||
log.error( "Exception cleaning up CacheManager " + manager, e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cacheManagers.clear();
|
catch ( Exception e ) {
|
||||||
|
log.error( "Exception cleaning up CacheManager ", e );
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
cacheManagers.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,11 +111,11 @@ public class ClusterAwareRegionFactory extends AbstractRegionFactory {
|
||||||
delegate.setCacheManager( existing );
|
delegate.setCacheManager( existing );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void start(Settings settings, Properties properties) throws CacheException {
|
public void start(Settings settings, Properties properties) throws CacheException {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if ( locallyAdded ) {
|
if ( locallyAdded ) {
|
||||||
cacheManagers.remove( cacheManagerName );
|
cacheManagers.remove( cacheManagerName );
|
||||||
|
@ -121,11 +123,12 @@ public class ClusterAwareRegionFactory extends AbstractRegionFactory {
|
||||||
delegate.stop();
|
delegate.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CollectionRegion buildCollectionRegion(String regionName, Properties properties,
|
public CollectionRegion buildCollectionRegion(String regionName, Properties properties,
|
||||||
CacheDataDescription metadata) throws CacheException {
|
CacheDataDescription metadata) throws CacheException {
|
||||||
return delegate.buildCollectionRegion( regionName, properties, metadata );
|
return delegate.buildCollectionRegion( regionName, properties, metadata );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public EntityRegion buildEntityRegion(String regionName, Properties properties,
|
public EntityRegion buildEntityRegion(String regionName, Properties properties,
|
||||||
CacheDataDescription metadata) throws CacheException {
|
CacheDataDescription metadata) throws CacheException {
|
||||||
return delegate.buildEntityRegion( regionName, properties, metadata );
|
return delegate.buildEntityRegion( regionName, properties, metadata );
|
||||||
|
@ -136,17 +139,17 @@ public class ClusterAwareRegionFactory extends AbstractRegionFactory {
|
||||||
throws CacheException {
|
throws CacheException {
|
||||||
return delegate.buildNaturalIdRegion( regionName, properties, metadata );
|
return delegate.buildNaturalIdRegion( regionName, properties, metadata );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties)
|
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties)
|
||||||
throws CacheException {
|
throws CacheException {
|
||||||
return delegate.buildQueryResultsRegion( regionName, properties );
|
return delegate.buildQueryResultsRegion( regionName, properties );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties)
|
public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties)
|
||||||
throws CacheException {
|
throws CacheException {
|
||||||
return delegate.buildTimestampsRegion( regionName, properties );
|
return delegate.buildTimestampsRegion( regionName, properties );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isMinimalPutsEnabledByDefault() {
|
public boolean isMinimalPutsEnabledByDefault() {
|
||||||
return delegate.isMinimalPutsEnabledByDefault();
|
return delegate.isMinimalPutsEnabledByDefault();
|
||||||
}
|
}
|
||||||
|
@ -155,7 +158,7 @@ public class ClusterAwareRegionFactory extends AbstractRegionFactory {
|
||||||
public AccessType getDefaultAccessType() {
|
public AccessType getDefaultAccessType() {
|
||||||
return AccessType.TRANSACTIONAL;
|
return AccessType.TRANSACTIONAL;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public long nextTimestamp() {
|
public long nextTimestamp() {
|
||||||
return delegate.nextTimestamp();
|
return delegate.nextTimestamp();
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ public abstract class DualNodeTestCase extends BaseCoreFunctionalTestCase {
|
||||||
protected void cleanupTransactionManagement() {
|
protected void cleanupTransactionManagement() {
|
||||||
DualNodeJtaTransactionManagerImpl.cleanupTransactions();
|
DualNodeJtaTransactionManagerImpl.cleanupTransactions();
|
||||||
DualNodeJtaTransactionManagerImpl.cleanupTransactionManagers();
|
DualNodeJtaTransactionManagerImpl.cleanupTransactionManagers();
|
||||||
|
ClusterAwareRegionFactory.clearCacheManagers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
|
@ -42,6 +42,10 @@ public class ClassLoadingIsolater implements MethodRule {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IsolatedClassLoaderProvider getProvider() {
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Statement apply(final Statement base, FrameworkMethod method, Object target) {
|
public Statement apply(final Statement base, FrameworkMethod method, Object target) {
|
||||||
return new Statement() {
|
return new Statement() {
|
||||||
|
|
|
@ -84,7 +84,6 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
|
||||||
private Boolean isAllTestsIgnored = null;
|
private Boolean isAllTestsIgnored = null;
|
||||||
private Object testInstance;
|
private Object testInstance;
|
||||||
private List<FrameworkMethod> computedTestMethods;
|
private List<FrameworkMethod> computedTestMethods;
|
||||||
private Boolean useNewMetamodel;
|
|
||||||
private boolean beforeClassMethodFailed;
|
private boolean beforeClassMethodFailed;
|
||||||
|
|
||||||
public CustomRunner(Class<?> clazz) throws InitializationError {
|
public CustomRunner(Class<?> clazz) throws InitializationError {
|
||||||
|
@ -268,10 +267,7 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useNewMetamodel() {
|
boolean useNewMetamodel() {
|
||||||
if ( useNewMetamodel == null ) {
|
return BaseUnitTestCase.isMetadataUsed();
|
||||||
useNewMetamodel = Boolean.valueOf( System.getProperty( BaseCoreFunctionalTestCase.USE_NEW_METADATA_MAPPINGS, "true" ) );
|
|
||||||
}
|
|
||||||
return useNewMetamodel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Ignore convertSkipToIgnore(FrameworkMethod frameworkMethod) {
|
protected Ignore convertSkipToIgnore(FrameworkMethod frameworkMethod) {
|
||||||
|
|
Loading…
Reference in New Issue