re-enable tests
remove org.hibernate.type.descriptor.java.JavaTypeDescriptorRegistry re-organize some tests
This commit is contained in:
parent
e76da92b04
commit
1f028095cf
|
@ -18,6 +18,7 @@ import org.hibernate.boot.model.convert.spi.JpaAttributeConverterCreationContext
|
||||||
import org.hibernate.metamodel.model.convert.internal.JpaAttributeConverterImpl;
|
import org.hibernate.metamodel.model.convert.internal.JpaAttributeConverterImpl;
|
||||||
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
|
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
|
||||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||||
|
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||||
|
|
||||||
import com.fasterxml.classmate.ResolvedType;
|
import com.fasterxml.classmate.ResolvedType;
|
||||||
|
|
||||||
|
@ -101,15 +102,23 @@ public abstract class AbstractConverterDescriptor implements ConverterDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public JpaAttributeConverter createJpaAttributeConverter(JpaAttributeConverterCreationContext context) {
|
public JpaAttributeConverter createJpaAttributeConverter(JpaAttributeConverterCreationContext context) {
|
||||||
|
final JavaTypeDescriptor<Object> converterJtd = context
|
||||||
|
.getJavaTypeDescriptorRegistry()
|
||||||
|
.getDescriptor( getAttributeConverterClass() );
|
||||||
|
|
||||||
|
final Class<?> domainJavaType = getDomainValueResolvedType().getErasedType();
|
||||||
|
final Class<?> jdbcJavaType = getRelationalValueResolvedType().getErasedType();
|
||||||
|
|
||||||
return new JpaAttributeConverterImpl(
|
return new JpaAttributeConverterImpl(
|
||||||
createManagedBean( context ),
|
createManagedBean( context ),
|
||||||
context.getJavaTypeDescriptorRegistry().getDescriptor( getAttributeConverterClass() ),
|
converterJtd,
|
||||||
context.getJavaTypeDescriptorRegistry().getDescriptor( getDomainValueResolvedType().getErasedType() ),
|
domainJavaType,
|
||||||
context.getJavaTypeDescriptorRegistry().getDescriptor( getRelationalValueResolvedType().getErasedType() )
|
jdbcJavaType,
|
||||||
|
context
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract ManagedBean<? extends AttributeConverter> createManagedBean(JpaAttributeConverterCreationContext context);
|
protected abstract ManagedBean<? extends AttributeConverter<?, ?>> createManagedBean(JpaAttributeConverterCreationContext context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ public class ClassBasedConverterDescriptor extends AbstractConverterDescriptor {
|
||||||
super( converterClass, forceAutoApply, classmateContext );
|
super( converterClass, forceAutoApply, classmateContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
protected ManagedBean<? extends AttributeConverter> createManagedBean(JpaAttributeConverterCreationContext context) {
|
protected ManagedBean<? extends AttributeConverter<?, ?>> createManagedBean(JpaAttributeConverterCreationContext context) {
|
||||||
return context.getManagedBeanRegistry().getBean( getAttributeConverterClass() );
|
//noinspection unchecked
|
||||||
|
return (ManagedBean<? extends AttributeConverter<?, ?>>) context.getManagedBeanRegistry().getBean( getAttributeConverterClass() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,16 +20,16 @@ import org.hibernate.resource.beans.spi.ProvidedInstanceManagedBeanImpl;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class InstanceBasedConverterDescriptor extends AbstractConverterDescriptor {
|
public class InstanceBasedConverterDescriptor extends AbstractConverterDescriptor {
|
||||||
private final AttributeConverter converterInstance;
|
private final AttributeConverter<?,?> converterInstance;
|
||||||
|
|
||||||
public InstanceBasedConverterDescriptor(
|
public InstanceBasedConverterDescriptor(
|
||||||
AttributeConverter converterInstance,
|
AttributeConverter<?,?> converterInstance,
|
||||||
ClassmateContext classmateContext) {
|
ClassmateContext classmateContext) {
|
||||||
this( converterInstance, null, classmateContext );
|
this( converterInstance, null, classmateContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstanceBasedConverterDescriptor(
|
public InstanceBasedConverterDescriptor(
|
||||||
AttributeConverter converterInstance,
|
AttributeConverter<?,?> converterInstance,
|
||||||
Boolean forceAutoApply,
|
Boolean forceAutoApply,
|
||||||
ClassmateContext classmateContext) {
|
ClassmateContext classmateContext) {
|
||||||
super( converterInstance.getClass(), forceAutoApply, classmateContext );
|
super( converterInstance.getClass(), forceAutoApply, classmateContext );
|
||||||
|
@ -37,8 +37,8 @@ public class InstanceBasedConverterDescriptor extends AbstractConverterDescripto
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
protected ManagedBean<? extends AttributeConverter<?, ?>> createManagedBean(JpaAttributeConverterCreationContext context) {
|
||||||
protected ManagedBean<? extends AttributeConverter> createManagedBean(JpaAttributeConverterCreationContext context) {
|
return new ProvidedInstanceManagedBeanImpl<>( converterInstance );
|
||||||
return new ProvidedInstanceManagedBeanImpl( converterInstance );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.hibernate.type.descriptor.ValueExtractor;
|
||||||
import org.hibernate.type.descriptor.converter.AttributeConverterMutabilityPlanImpl;
|
import org.hibernate.type.descriptor.converter.AttributeConverterMutabilityPlanImpl;
|
||||||
import org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter;
|
import org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter;
|
||||||
import org.hibernate.type.descriptor.java.BasicJavaDescriptor;
|
import org.hibernate.type.descriptor.java.BasicJavaDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
||||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
|
@ -114,9 +115,18 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
|
||||||
? explicitMutabilityPlanAccess.apply( typeConfiguration )
|
? explicitMutabilityPlanAccess.apply( typeConfiguration )
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
final MutabilityPlan mutabilityPlan = explicitMutabilityPlan != null
|
|
||||||
? explicitMutabilityPlan
|
final MutabilityPlan mutabilityPlan;
|
||||||
: new AttributeConverterMutabilityPlanImpl( converter, true );
|
if ( explicitMutabilityPlan != null ) {
|
||||||
|
mutabilityPlan = explicitMutabilityPlan;
|
||||||
|
}
|
||||||
|
else if ( domainJtd.getMutabilityPlan().isMutable() ) {
|
||||||
|
mutabilityPlan = new AttributeConverterMutabilityPlanImpl( converter, true );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mutabilityPlan = ImmutableMutabilityPlan.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
return new NamedConverterResolution(
|
return new NamedConverterResolution(
|
||||||
domainJtd,
|
domainJtd,
|
||||||
relationalJtd,
|
relationalJtd,
|
||||||
|
|
|
@ -8,9 +8,12 @@ package org.hibernate.metamodel.model.convert.internal;
|
||||||
|
|
||||||
import javax.persistence.AttributeConverter;
|
import javax.persistence.AttributeConverter;
|
||||||
|
|
||||||
|
import org.hibernate.boot.model.convert.spi.JpaAttributeConverterCreationContext;
|
||||||
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
|
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
|
||||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry;
|
||||||
|
import org.hibernate.type.descriptor.java.spi.RegistryHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard implementation of JpaAttributeConverter
|
* Standard implementation of JpaAttributeConverter
|
||||||
|
@ -19,19 +22,37 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||||
*/
|
*/
|
||||||
public class JpaAttributeConverterImpl<O,R> implements JpaAttributeConverter<O,R> {
|
public class JpaAttributeConverterImpl<O,R> implements JpaAttributeConverter<O,R> {
|
||||||
private final ManagedBean<? extends AttributeConverter<O,R>> attributeConverterBean;
|
private final ManagedBean<? extends AttributeConverter<O,R>> attributeConverterBean;
|
||||||
private final JavaTypeDescriptor<? extends AttributeConverter<O, R>> converterJavaTypeDescriptor;
|
private final JavaTypeDescriptor<? extends AttributeConverter<O, R>> converterJtd;
|
||||||
private final JavaTypeDescriptor<O> domainJavaTypeDescriptor;
|
private final JavaTypeDescriptor<O> domainJtd;
|
||||||
private final JavaTypeDescriptor<R> relationalJavaTypeDescriptor;
|
private final JavaTypeDescriptor<R> jdbcJtd;
|
||||||
|
|
||||||
public JpaAttributeConverterImpl(
|
public JpaAttributeConverterImpl(
|
||||||
ManagedBean<? extends AttributeConverter<O, R>> attributeConverterBean,
|
ManagedBean<? extends AttributeConverter<O, R>> attributeConverterBean,
|
||||||
JavaTypeDescriptor<? extends AttributeConverter<O,R>> converterJavaTypeDescriptor,
|
JavaTypeDescriptor<? extends AttributeConverter<O,R>> converterJtd,
|
||||||
JavaTypeDescriptor<O> domainJavaTypeDescriptor,
|
JavaTypeDescriptor<O> domainJtd,
|
||||||
JavaTypeDescriptor<R> relationalJavaTypeDescriptor) {
|
JavaTypeDescriptor<R> jdbcJtd) {
|
||||||
this.attributeConverterBean = attributeConverterBean;
|
this.attributeConverterBean = attributeConverterBean;
|
||||||
this.converterJavaTypeDescriptor = converterJavaTypeDescriptor;
|
this.converterJtd = converterJtd;
|
||||||
this.domainJavaTypeDescriptor = domainJavaTypeDescriptor;
|
this.domainJtd = domainJtd;
|
||||||
this.relationalJavaTypeDescriptor = relationalJavaTypeDescriptor;
|
this.jdbcJtd = jdbcJtd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JpaAttributeConverterImpl(
|
||||||
|
ManagedBean<? extends AttributeConverter<O,R>> attributeConverterBean,
|
||||||
|
JavaTypeDescriptor<? extends AttributeConverter<O,R>> converterJtd,
|
||||||
|
Class<O> domainJavaType,
|
||||||
|
Class<R> jdbcJavaType,
|
||||||
|
JpaAttributeConverterCreationContext context) {
|
||||||
|
this.attributeConverterBean = attributeConverterBean;
|
||||||
|
this.converterJtd = converterJtd;
|
||||||
|
|
||||||
|
final JavaTypeDescriptorRegistry jtdRegistry = context.getJavaTypeDescriptorRegistry();
|
||||||
|
|
||||||
|
jdbcJtd = jtdRegistry.getDescriptor( jdbcJavaType );
|
||||||
|
domainJtd = jtdRegistry.resolveDescriptor(
|
||||||
|
domainJavaType,
|
||||||
|
() -> RegistryHelper.INSTANCE.createTypeDescriptor( domainJavaType, context.getTypeConfiguration() )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +72,7 @@ public class JpaAttributeConverterImpl<O,R> implements JpaAttributeConverter<O,R
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaTypeDescriptor<? extends AttributeConverter<O, R>> getConverterJavaTypeDescriptor() {
|
public JavaTypeDescriptor<? extends AttributeConverter<O, R>> getConverterJavaTypeDescriptor() {
|
||||||
return converterJavaTypeDescriptor;
|
return converterJtd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,11 +87,11 @@ public class JpaAttributeConverterImpl<O,R> implements JpaAttributeConverter<O,R
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaTypeDescriptor<O> getDomainJavaTypeDescriptor() {
|
public JavaTypeDescriptor<O> getDomainJavaTypeDescriptor() {
|
||||||
return domainJavaTypeDescriptor;
|
return domainJtd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaTypeDescriptor<R> getRelationalJavaTypeDescriptor() {
|
public JavaTypeDescriptor<R> getRelationalJavaTypeDescriptor() {
|
||||||
return relationalJavaTypeDescriptor;
|
return jdbcJtd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,10 +61,10 @@ public class AttributeConverterTypeAdapter<T> extends AbstractSingleColumnStanda
|
||||||
this.relationalJtd = relationalJtd;
|
this.relationalJtd = relationalJtd;
|
||||||
this.attributeConverter = attributeConverter;
|
this.attributeConverter = attributeConverter;
|
||||||
|
|
||||||
|
// NOTE : the way that JpaAttributeConverter get built, their "domain JTD" already
|
||||||
|
// contains the proper MutabilityPlan based on whether the `@Immuatble` is present
|
||||||
if ( mutabilityPlan == null ) {
|
if ( mutabilityPlan == null ) {
|
||||||
this.mutabilityPlan = domainJtd.getMutabilityPlan().isMutable()
|
this.mutabilityPlan = (MutabilityPlan<T>) attributeConverter.getDomainJavaTypeDescriptor().getMutabilityPlan();
|
||||||
? new AttributeConverterMutabilityPlanImpl<>( attributeConverter, true )
|
|
||||||
: ImmutableMutabilityPlan.INSTANCE;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.mutabilityPlan = mutabilityPlan;
|
this.mutabilityPlan = mutabilityPlan;
|
||||||
|
|
|
@ -1,196 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
||||||
*/
|
|
||||||
package org.hibernate.type.descriptor.java;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import javax.persistence.AttributeConverter;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.annotations.Immutable;
|
|
||||||
import org.hibernate.annotations.Remove;
|
|
||||||
import org.hibernate.internal.CoreLogging;
|
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
|
||||||
import org.hibernate.type.descriptor.WrapperOptions;
|
|
||||||
import org.hibernate.type.descriptor.java.spi.RegistryHelper;
|
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basically a map from {@link Class} -> {@link JavaTypeDescriptor}
|
|
||||||
*
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*
|
|
||||||
* @deprecated Use (5.3) Use {@link org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Remove
|
|
||||||
public class JavaTypeDescriptorRegistry implements Serializable {
|
|
||||||
private static final CoreMessageLogger log = CoreLogging.messageLogger( JavaTypeDescriptorRegistry.class );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated (5.3) Use {@link TypeConfiguration#getJavaTypeDescriptorRegistry()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static final JavaTypeDescriptorRegistry INSTANCE = new JavaTypeDescriptorRegistry();
|
|
||||||
|
|
||||||
private ConcurrentHashMap<Class, JavaTypeDescriptor> descriptorsByClass = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public JavaTypeDescriptorRegistry() {
|
|
||||||
addDescriptorInternal( ByteTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( BooleanTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( CharacterTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( ShortTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( IntegerTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( LongTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( FloatTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( DoubleTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( BigDecimalTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( BigIntegerTypeDescriptor.INSTANCE );
|
|
||||||
|
|
||||||
addDescriptorInternal( StringTypeDescriptor.INSTANCE );
|
|
||||||
|
|
||||||
addDescriptorInternal( BlobTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( ClobTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( NClobTypeDescriptor.INSTANCE );
|
|
||||||
|
|
||||||
addDescriptorInternal( ByteArrayTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( CharacterArrayTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( PrimitiveByteArrayTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( PrimitiveCharacterArrayTypeDescriptor.INSTANCE );
|
|
||||||
|
|
||||||
addDescriptorInternal( DurationJavaDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( InstantJavaDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( LocalDateJavaDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( LocalDateTimeJavaDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( OffsetDateTimeJavaDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( OffsetTimeJavaDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( ZonedDateTimeJavaDescriptor.INSTANCE );
|
|
||||||
|
|
||||||
addDescriptorInternal( CalendarTypeDescriptor.INSTANCE );
|
|
||||||
descriptorsByClass.put( java.util.Date.class, JdbcTimestampTypeDescriptor.INSTANCE );
|
|
||||||
descriptorsByClass.put( java.sql.Timestamp.class, JdbcTimestampTypeDescriptor.INSTANCE );
|
|
||||||
descriptorsByClass.put( java.sql.Date.class, JdbcDateTypeDescriptor.INSTANCE );
|
|
||||||
descriptorsByClass.put( java.sql.Time.class, JdbcTimeTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( TimeZoneTypeDescriptor.INSTANCE );
|
|
||||||
|
|
||||||
addDescriptorInternal( ClassTypeDescriptor.INSTANCE );
|
|
||||||
|
|
||||||
addDescriptorInternal( CurrencyTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( LocaleTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( UrlTypeDescriptor.INSTANCE );
|
|
||||||
addDescriptorInternal( UUIDTypeDescriptor.INSTANCE );
|
|
||||||
}
|
|
||||||
|
|
||||||
private JavaTypeDescriptor addDescriptorInternal(JavaTypeDescriptor descriptor) {
|
|
||||||
return descriptorsByClass.put( descriptor.getJavaTypeClass(), descriptor );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the given descriptor to this registry
|
|
||||||
*
|
|
||||||
* @param descriptor The descriptor to add.
|
|
||||||
*
|
|
||||||
* @deprecated (5.3) Use {@link org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry#addDescriptor(JavaTypeDescriptor)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void addDescriptor(JavaTypeDescriptor descriptor) {
|
|
||||||
JavaTypeDescriptor old = addDescriptorInternal( descriptor );
|
|
||||||
if ( old != null ) {
|
|
||||||
log.debugf(
|
|
||||||
"JavaTypeDescriptorRegistry entry replaced : %s -> %s (was %s)",
|
|
||||||
descriptor.getJavaType(),
|
|
||||||
descriptor,
|
|
||||||
old
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated (5.3) Use {@link org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry#getDescriptor(Class)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <J> JavaTypeDescriptor<J> getDescriptor(Class<J> cls) {
|
|
||||||
return RegistryHelper.INSTANCE.resolveDescriptor(
|
|
||||||
descriptorsByClass,
|
|
||||||
cls,
|
|
||||||
() -> {
|
|
||||||
if ( Serializable.class.isAssignableFrom( cls ) ) {
|
|
||||||
return new SerializableTypeDescriptor( cls );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !AttributeConverter.class.isAssignableFrom( cls ) ) {
|
|
||||||
log.debugf(
|
|
||||||
"Could not find matching JavaTypeDescriptor for requested Java class [%s]; using fallback. " +
|
|
||||||
"This means Hibernate does not know how to perform certain basic operations in relation to this Java type.",
|
|
||||||
cls.getName()
|
|
||||||
);
|
|
||||||
checkEqualsAndHashCode( cls );
|
|
||||||
}
|
|
||||||
|
|
||||||
return new FallbackJavaTypeDescriptor<>( cls );
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void checkEqualsAndHashCode(Class javaType) {
|
|
||||||
if ( !ReflectHelper.overridesEquals( javaType ) || !ReflectHelper.overridesHashCode( javaType ) ) {
|
|
||||||
log.unknownJavaTypeNoEqualsHashCode( javaType );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static class FallbackJavaTypeDescriptor<T> extends AbstractClassTypeDescriptor<T> {
|
|
||||||
protected FallbackJavaTypeDescriptor(final Class<T> type) {
|
|
||||||
super( type, createMutabilityPlan( type ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static <T> MutabilityPlan<T> createMutabilityPlan(final Class<T> type) {
|
|
||||||
if ( type.isAnnotationPresent( Immutable.class ) ) {
|
|
||||||
return ImmutableMutabilityPlan.INSTANCE;
|
|
||||||
}
|
|
||||||
// MutableMutabilityPlan is the "safest" option, but we do not necessarily know how to deepCopy etc...
|
|
||||||
return new MutableMutabilityPlan<T>() {
|
|
||||||
@Override
|
|
||||||
protected T deepCopyNotNull(T value) {
|
|
||||||
throw new HibernateException(
|
|
||||||
"Not known how to deep copy value of type: [" + type
|
|
||||||
.getName() + "]"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString(T value) {
|
|
||||||
return value == null ? "<null>" : value.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T fromString(String string) {
|
|
||||||
throw new HibernateException(
|
|
||||||
"Not known how to convert String to given type [" + getJavaType().getTypeName() + "]"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <X> X unwrap(T value, Class<X> type, WrapperOptions options) {
|
|
||||||
return (X) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <X> T wrap(X value, WrapperOptions options) {
|
|
||||||
return (T) value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -44,7 +44,11 @@ public class SerializableTypeDescriptor<T extends Serializable> extends Abstract
|
||||||
}
|
}
|
||||||
|
|
||||||
public SerializableTypeDescriptor(Class<T> type) {
|
public SerializableTypeDescriptor(Class<T> type) {
|
||||||
super( type, createMutabilityPlan( type ) );
|
this( type, createMutabilityPlan( type ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public SerializableTypeDescriptor(Class<T> type, MutabilityPlan<T> mutabilityPlan) {
|
||||||
|
super( type, mutabilityPlan == null ? createMutabilityPlan( type ) : mutabilityPlan );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -8,6 +8,7 @@ package org.hibernate.type.descriptor.java.spi;
|
||||||
|
|
||||||
import org.hibernate.type.descriptor.WrapperOptions;
|
import org.hibernate.type.descriptor.WrapperOptions;
|
||||||
import org.hibernate.type.descriptor.java.AbstractClassTypeDescriptor;
|
import org.hibernate.type.descriptor.java.AbstractClassTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
||||||
|
|
||||||
|
@ -22,6 +23,10 @@ public class JavaTypeDescriptorBasicAdaptor<T> extends AbstractClassTypeDescript
|
||||||
super( type );
|
super( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JavaTypeDescriptorBasicAdaptor(Class<T> type, MutabilityPlan<T> mutabilityPlan) {
|
||||||
|
super( type, mutabilityPlan );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqlTypeDescriptor getJdbcRecommendedSqlType(SqlTypeDescriptorIndicators context) {
|
public SqlTypeDescriptor getJdbcRecommendedSqlType(SqlTypeDescriptorIndicators context) {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
|
|
|
@ -12,9 +12,16 @@ import java.lang.reflect.Type;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Immutable;
|
||||||
|
import org.hibernate.annotations.Mutability;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
|
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||||
|
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||||
import org.hibernate.type.descriptor.java.AbstractClassTypeDescriptor;
|
import org.hibernate.type.descriptor.java.AbstractClassTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor;
|
import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
||||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||||
import org.hibernate.type.descriptor.java.SerializableTypeDescriptor;
|
import org.hibernate.type.descriptor.java.SerializableTypeDescriptor;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
import org.hibernate.type.spi.TypeConfigurationAware;
|
import org.hibernate.type.spi.TypeConfigurationAware;
|
||||||
|
@ -35,7 +42,6 @@ public class JavaTypeDescriptorRegistry implements JavaTypeDescriptorBaseline.Ba
|
||||||
private final TypeConfiguration typeConfiguration;
|
private final TypeConfiguration typeConfiguration;
|
||||||
private final ConcurrentHashMap<Type, JavaTypeDescriptor<?>> descriptorsByType = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Type, JavaTypeDescriptor<?>> descriptorsByType = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public JavaTypeDescriptorRegistry(TypeConfiguration typeConfiguration) {
|
public JavaTypeDescriptorRegistry(TypeConfiguration typeConfiguration) {
|
||||||
this.typeConfiguration = typeConfiguration;
|
this.typeConfiguration = typeConfiguration;
|
||||||
JavaTypeDescriptorBaseline.prime( this );
|
JavaTypeDescriptorBaseline.prime( this );
|
||||||
|
@ -131,8 +137,6 @@ public class JavaTypeDescriptorRegistry implements JavaTypeDescriptorBaseline.Ba
|
||||||
return resolveDescriptor(
|
return resolveDescriptor(
|
||||||
javaType,
|
javaType,
|
||||||
() -> {
|
() -> {
|
||||||
// the fallback will always be a basic type
|
|
||||||
final AbstractClassTypeDescriptor<J> fallbackDescriptor;
|
|
||||||
final Class<?> javaTypeClass;
|
final Class<?> javaTypeClass;
|
||||||
if ( javaType instanceof Class<?> ) {
|
if ( javaType instanceof Class<?> ) {
|
||||||
javaTypeClass = (Class<?>) javaType;
|
javaTypeClass = (Class<?>) javaType;
|
||||||
|
@ -142,25 +146,10 @@ public class JavaTypeDescriptorRegistry implements JavaTypeDescriptorBaseline.Ba
|
||||||
javaTypeClass = (Class<?>) parameterizedType.getRawType();
|
javaTypeClass = (Class<?>) parameterizedType.getRawType();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( javaTypeClass.isEnum() ) {
|
return RegistryHelper.INSTANCE.createTypeDescriptor(
|
||||||
//noinspection rawtypes
|
javaTypeClass,
|
||||||
fallbackDescriptor = new EnumJavaTypeDescriptor( javaTypeClass );
|
typeConfiguration
|
||||||
}
|
);
|
||||||
else if ( Serializable.class.isAssignableFrom( javaTypeClass ) ) {
|
|
||||||
//noinspection rawtypes
|
|
||||||
fallbackDescriptor = new SerializableTypeDescriptor( javaTypeClass );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//noinspection rawtypes
|
|
||||||
fallbackDescriptor = new JavaTypeDescriptorBasicAdaptor( javaTypeClass );
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo (6.0) : here we assume that all temporal type descriptors are registered
|
|
||||||
// ahead of time. Allow for on-the-fly temporal types? The 2 impediments for that are:
|
|
||||||
// 1) How can we recognize non-JDK date/time types?
|
|
||||||
// 2) What is the temporal precision for the types we have deemed temporal?
|
|
||||||
|
|
||||||
return fallbackDescriptor;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,19 +6,26 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.type.descriptor.java.spi;
|
package org.hibernate.type.descriptor.java.spi;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.io.Serializable;
|
||||||
import java.util.function.Supplier;
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Immutable;
|
||||||
|
import org.hibernate.annotations.Mutability;
|
||||||
|
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||||
|
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||||
import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor;
|
import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
||||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||||
import org.jboss.logging.Logger;
|
import org.hibernate.type.descriptor.java.SerializableTypeDescriptor;
|
||||||
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class RegistryHelper {
|
public class RegistryHelper {
|
||||||
private static final Logger log = Logger.getLogger( RegistryHelper.class );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton access
|
* Singleton access
|
||||||
|
@ -29,33 +36,55 @@ public class RegistryHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <J> JavaTypeDescriptor<J> resolveDescriptor(
|
public <J> JavaTypeDescriptor<J> createTypeDescriptor(Type javaType, TypeConfiguration typeConfiguration) {
|
||||||
Map<Class,JavaTypeDescriptor> descriptorsByClass,
|
return createTypeDescriptor(
|
||||||
Class<J> cls,
|
javaType,
|
||||||
Supplier<JavaTypeDescriptor<J>> defaultValueSupplier) {
|
(javaTypeClass) -> {
|
||||||
if ( cls == null ) {
|
if ( javaTypeClass.isAnnotationPresent( Immutable.class ) ) {
|
||||||
throw new IllegalArgumentException( "Class passed to locate JavaTypeDescriptor cannot be null" );
|
return ImmutableMutabilityPlan.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( javaTypeClass.isAnnotationPresent( Mutability.class ) ) {
|
||||||
|
final Mutability annotation = javaTypeClass.getAnnotation( Mutability.class );
|
||||||
|
final Class<? extends MutabilityPlan<?>> planClass = annotation.value();
|
||||||
|
final ManagedBeanRegistry managedBeanRegistry = typeConfiguration
|
||||||
|
.getServiceRegistry()
|
||||||
|
.getService( ManagedBeanRegistry.class );
|
||||||
|
final ManagedBean<? extends MutabilityPlan<?>> planBean = managedBeanRegistry.getBean( planClass );
|
||||||
|
return (MutabilityPlan<J>) planBean.getBeanInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ImmutableMutabilityPlan.INSTANCE;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <J> JavaTypeDescriptor<J> createTypeDescriptor(
|
||||||
|
Type javaType,
|
||||||
|
Function<Class<J>,MutabilityPlan<J>> mutabilityPlanResolver) {
|
||||||
|
final Class<J> javaTypeClass;
|
||||||
|
if ( javaType instanceof Class<?> ) {
|
||||||
|
javaTypeClass = (Class<J>) javaType;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final ParameterizedType parameterizedType = (ParameterizedType) javaType;
|
||||||
|
javaTypeClass = (Class<J>) parameterizedType.getRawType();
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaTypeDescriptor<J> descriptor = descriptorsByClass.get( cls );
|
if ( javaTypeClass.isEnum() ) {
|
||||||
if ( descriptor != null ) {
|
// enums are unequivocally immutable
|
||||||
return descriptor;
|
//noinspection rawtypes
|
||||||
|
return new EnumJavaTypeDescriptor( javaTypeClass );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cls.isEnum() ) {
|
final MutabilityPlan<J> plan = mutabilityPlanResolver.apply( javaTypeClass );
|
||||||
descriptor = new EnumJavaTypeDescriptor( cls );
|
|
||||||
descriptorsByClass.put( cls, descriptor );
|
if ( Serializable.class.isAssignableFrom( javaTypeClass ) ) {
|
||||||
return descriptor;
|
//noinspection rawtypes
|
||||||
|
return new SerializableTypeDescriptor( javaTypeClass, plan );
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the first "assignable" match
|
return new JavaTypeDescriptorBasicAdaptor<>( javaTypeClass, plan );
|
||||||
for ( Map.Entry<Class, JavaTypeDescriptor> entry : descriptorsByClass.entrySet() ) {
|
|
||||||
if ( entry.getKey().isAssignableFrom( cls ) ) {
|
|
||||||
log.debugf( "Using cached JavaTypeDescriptor instance for Java class [%s]", cls.getName() );
|
|
||||||
return entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultValueSupplier.get();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.converter;
|
package org.hibernate.orm.test.mapping.converted;
|
||||||
|
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.util.Locale;
|
||||||
import javax.persistence.AttributeConverter;
|
import javax.persistence.AttributeConverter;
|
||||||
import javax.persistence.Cacheable;
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.Convert;
|
import javax.persistence.Convert;
|
||||||
|
@ -18,18 +20,21 @@ import org.hibernate.Session;
|
||||||
import org.hibernate.annotations.Immutable;
|
import org.hibernate.annotations.Immutable;
|
||||||
import org.hibernate.boot.MetadataBuilder;
|
import org.hibernate.boot.MetadataBuilder;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.metamodel.spi.MetamodelImplementor;
|
import org.hibernate.type.descriptor.WrapperOptions;
|
||||||
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
||||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptorRegistry;
|
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||||
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
@ -39,20 +44,66 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
*/
|
*/
|
||||||
public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalTestCase {
|
public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
|
|
||||||
|
private static int mutableToDatabaseCallCount;
|
||||||
|
private static int mutableToDomainCallCount;
|
||||||
|
|
||||||
|
private static int immutableToDatabaseCallCount;
|
||||||
|
private static int immutableToDomainCallCount;
|
||||||
|
|
||||||
|
private static int pseudoMutableToDatabaseCallCount;
|
||||||
|
private static int pseudoMutableToDomainCallCount;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue( jiraKey = "HHH-11098" )
|
||||||
|
public void testIt() {
|
||||||
|
// create data and check assertions
|
||||||
|
inTransaction(
|
||||||
|
(session) -> session.persist( new TheEntity( 1 ) )
|
||||||
|
);
|
||||||
|
|
||||||
|
// assertions based on the persist call
|
||||||
|
assertThat( mutableToDomainCallCount, is(1 ) ); // 1 instead of 0 because of the deep copy call
|
||||||
|
assertThat( mutableToDatabaseCallCount, is(2 ) ); // 2 instead of 1 because of the deep copy call
|
||||||
|
|
||||||
|
assertThat( immutableToDomainCallCount, is(0 ) ); // logical
|
||||||
|
assertThat( immutableToDatabaseCallCount, is(1 ) ); // logical
|
||||||
|
|
||||||
|
assertThat( pseudoMutableToDomainCallCount, is(0 ) ); // was 1 (like mutable) before the JavaTypeDescriptor registration
|
||||||
|
assertThat( pseudoMutableToDatabaseCallCount, is(1 ) ); // was 2 (like mutable) before the JavaTypeDescriptor registration
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void clearCounts() {
|
||||||
|
// in case we add additional tests
|
||||||
|
sessionFactory().getStatistics().clear();
|
||||||
|
|
||||||
|
mutableToDatabaseCallCount = 0;
|
||||||
|
mutableToDomainCallCount = 0;
|
||||||
|
|
||||||
|
immutableToDatabaseCallCount = 0;
|
||||||
|
immutableToDomainCallCount = 0;
|
||||||
|
|
||||||
|
pseudoMutableToDatabaseCallCount = 0;
|
||||||
|
pseudoMutableToDomainCallCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void dropTestData() {
|
||||||
|
inTransaction(
|
||||||
|
(session) -> session.createQuery( "delete TheEntity" ).executeUpdate()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureMetadataBuilder(MetadataBuilder metadataBuilder) {
|
protected void configureMetadataBuilder(MetadataBuilder metadataBuilder) {
|
||||||
((MetadataBuilderImpl)metadataBuilder).contributeJavaTypeDescriptor(new JavaTypeDescriptorRegistry.FallbackJavaTypeDescriptor( MutableState2.class ) {
|
( (TypeContributions) metadataBuilder ).contributeJavaTypeDescriptor( PseudoMutableStateJavaTypeDescriptor.INSTANCE );
|
||||||
@Override
|
|
||||||
public MutabilityPlan getMutabilityPlan() {
|
|
||||||
return ImmutableMutabilityPlan.INSTANCE;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
|
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
|
||||||
super.configureStandardServiceRegistryBuilder( ssrb );
|
super.configureStandardServiceRegistryBuilder( ssrb );
|
||||||
|
|
||||||
|
// to make sure we get the deepCopy calls
|
||||||
ssrb.applySetting( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" );
|
ssrb.applySetting( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" );
|
||||||
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
|
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
|
||||||
}
|
}
|
||||||
|
@ -60,48 +111,9 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
|
||||||
@Override
|
@Override
|
||||||
protected void applyMetadataSources(MetadataSources sources) {
|
protected void applyMetadataSources(MetadataSources sources) {
|
||||||
super.applyMetadataSources( sources );
|
super.applyMetadataSources( sources );
|
||||||
|
|
||||||
sources.addAnnotatedClass( TheEntity.class );
|
sources.addAnnotatedClass( TheEntity.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestForIssue( jiraKey = "HHH-11098" )
|
|
||||||
public void testIt() {
|
|
||||||
// set up test data
|
|
||||||
Session session = openSession();
|
|
||||||
( (MetamodelImplementor) session.getMetamodel() ).getTypeConfiguration()
|
|
||||||
.getJavaTypeDescriptorRegistry()
|
|
||||||
.addDescriptor(
|
|
||||||
new JavaTypeDescriptorRegistry.FallbackJavaTypeDescriptor( MutableState2.class ) {
|
|
||||||
@Override
|
|
||||||
public MutabilityPlan getMutabilityPlan() {
|
|
||||||
return ImmutableMutabilityPlan.INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
session.beginTransaction();
|
|
||||||
session.persist( new TheEntity(1) );
|
|
||||||
session.getTransaction().commit();
|
|
||||||
session.close();
|
|
||||||
|
|
||||||
// assertions based on the persist call
|
|
||||||
assertThat( mutableToDomainCallCount, is(1) ); // 1 instead of 0 because of the deep copy call
|
|
||||||
assertThat( mutableToDatabaseCallCount, is(2) ); // 2 instead of 1 because of the deep copy call
|
|
||||||
|
|
||||||
assertThat( immutableToDomainCallCount, is(0) ); // logical
|
|
||||||
assertThat( immutableToDatabaseCallCount, is(1) ); // logical
|
|
||||||
|
|
||||||
assertThat( immutableMutableToDomainCallCount, is(0) ); // was 1 (like mutable) before the JavaTypeDescriptor registration
|
|
||||||
assertThat( immutableMutableToDatabaseCallCount, is(1) ); // was 2 (like mutable) before the JavaTypeDescriptor registration
|
|
||||||
|
|
||||||
// clean up test data
|
|
||||||
session = openSession();
|
|
||||||
session.beginTransaction();
|
|
||||||
session.delete( session.byId( TheEntity.class ).getReference( 1 ) );
|
|
||||||
session.getTransaction().commit();
|
|
||||||
session.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Entity( name = "TheEntity")
|
@Entity( name = "TheEntity")
|
||||||
@Table( name = "T_ENTITY" )
|
@Table( name = "T_ENTITY" )
|
||||||
|
@ -116,8 +128,8 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
|
||||||
@Convert( converter = ImmutableConverterImpl.class )
|
@Convert( converter = ImmutableConverterImpl.class )
|
||||||
private ImmutableState immutableState;
|
private ImmutableState immutableState;
|
||||||
|
|
||||||
@Convert( converter = ImmutableMutable2ConverterImpl.class )
|
@Convert( converter = PseudoMutableConverterImpl.class )
|
||||||
private MutableState2 immutableMutableState;
|
private PseudoMutableState immutableMutableState;
|
||||||
|
|
||||||
public TheEntity() {
|
public TheEntity() {
|
||||||
}
|
}
|
||||||
|
@ -127,34 +139,10 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
|
||||||
|
|
||||||
this.mutableState = new MutableState( id.toString() );
|
this.mutableState = new MutableState( id.toString() );
|
||||||
this.immutableState = new ImmutableState( id.toString() );
|
this.immutableState = new ImmutableState( id.toString() );
|
||||||
this.immutableMutableState = new MutableState2( id.toString() );
|
this.immutableMutableState = new PseudoMutableState( id.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
|
||||||
public void clearCounts() {
|
|
||||||
// in case we add additional tests
|
|
||||||
sessionFactory().getStatistics().clear();
|
|
||||||
|
|
||||||
mutableToDatabaseCallCount = 0;
|
|
||||||
mutableToDomainCallCount = 0;
|
|
||||||
|
|
||||||
immutableToDatabaseCallCount = 0;
|
|
||||||
immutableToDomainCallCount = 0;
|
|
||||||
|
|
||||||
immutableMutableToDatabaseCallCount = 0;
|
|
||||||
immutableMutableToDomainCallCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int mutableToDatabaseCallCount;
|
|
||||||
private static int mutableToDomainCallCount;
|
|
||||||
|
|
||||||
private static int immutableToDatabaseCallCount;
|
|
||||||
private static int immutableToDomainCallCount;
|
|
||||||
|
|
||||||
private static int immutableMutableToDatabaseCallCount;
|
|
||||||
private static int immutableMutableToDomainCallCount;
|
|
||||||
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Purely mutable state
|
// Purely mutable state
|
||||||
|
@ -267,10 +255,10 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Mutable state we treat as immutable
|
// Mutable state we treat as immutable
|
||||||
|
|
||||||
public static class MutableState2 {
|
public static class PseudoMutableState {
|
||||||
private String state;
|
private String state;
|
||||||
|
|
||||||
public MutableState2(String state) {
|
public PseudoMutableState(String state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +281,7 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MutableState2 that = (MutableState2) o;
|
PseudoMutableState that = (PseudoMutableState) o;
|
||||||
|
|
||||||
return getState() != null ? getState().equals( that.getState() ) : that.getState() == null;
|
return getState() != null ? getState().equals( that.getState() ) : that.getState() == null;
|
||||||
|
|
||||||
|
@ -306,20 +294,76 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Converter
|
@Converter
|
||||||
public static class ImmutableMutable2ConverterImpl implements AttributeConverter<MutableState2,String> {
|
public static class PseudoMutableConverterImpl implements AttributeConverter<PseudoMutableState,String> {
|
||||||
@Override
|
@Override
|
||||||
public String convertToDatabaseColumn(MutableState2 attribute) {
|
public String convertToDatabaseColumn(PseudoMutableState attribute) {
|
||||||
immutableMutableToDatabaseCallCount++;
|
pseudoMutableToDatabaseCallCount++;
|
||||||
return attribute == null ? null : attribute.getState();
|
return attribute == null ? null : attribute.getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MutableState2 convertToEntityAttribute(String dbData) {
|
public PseudoMutableState convertToEntityAttribute(String dbData) {
|
||||||
immutableMutableToDomainCallCount++;
|
pseudoMutableToDomainCallCount++;
|
||||||
return new MutableState2( dbData );
|
return new PseudoMutableState( dbData );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PseudoMutableStateJavaTypeDescriptor implements JavaTypeDescriptor<PseudoMutableState> {
|
||||||
|
/**
|
||||||
|
* Singleton access
|
||||||
|
*/
|
||||||
|
public static final PseudoMutableStateJavaTypeDescriptor INSTANCE = new PseudoMutableStateJavaTypeDescriptor();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<PseudoMutableState> getJavaTypeClass() {
|
||||||
|
return PseudoMutableState.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutabilityPlan<PseudoMutableState> getMutabilityPlan() {
|
||||||
|
//noinspection unchecked
|
||||||
|
return ImmutableMutabilityPlan.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SqlTypeDescriptor getJdbcRecommendedSqlType(SqlTypeDescriptorIndicators context) {
|
||||||
|
return context.getTypeConfiguration().getSqlTypeDescriptorRegistry().getDescriptor( Types.VARCHAR );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PseudoMutableState fromString(String string) {
|
||||||
|
return string == null ? null : new PseudoMutableState( string );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <X> X unwrap(PseudoMutableState value, Class<X> type, WrapperOptions options) {
|
||||||
|
if ( value == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( PseudoMutableState.class.equals( type ) ) {
|
||||||
|
return (X) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( String.class.equals( type ) ) {
|
||||||
|
return (X) value.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
Locale.ROOT,
|
||||||
|
"Cannot convert value '%s' to type `%s`",
|
||||||
|
value.state,
|
||||||
|
type
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <X> PseudoMutableState wrap(X value, WrapperOptions options) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,12 @@
|
||||||
package org.hibernate.type.descriptor.java;
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||||
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
|
*/
|
||||||
|
package org.hibernate.orm.test.type.descriptor.java;
|
||||||
|
|
||||||
|
import org.hibernate.type.descriptor.java.BooleanTypeDescriptor;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||||
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
|
*/
|
||||||
|
package org.hibernate.orm.test.type.descriptor.java;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
import org.hibernate.type.descriptor.WrapperOptions;
|
||||||
|
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||||
|
import org.hibernate.type.descriptor.java.StringTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry;
|
||||||
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
||||||
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andrea Boriero
|
||||||
|
*/
|
||||||
|
public class JavaTypeDescriptorRegistryTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetJavaTypeDescriptorRegistry() {
|
||||||
|
final TypeConfiguration typeConfiguration = new TypeConfiguration();
|
||||||
|
final JavaTypeDescriptorRegistry registry = new JavaTypeDescriptorRegistry( typeConfiguration );
|
||||||
|
|
||||||
|
final JavaTypeDescriptor<String> descriptor = registry.getDescriptor( String.class );
|
||||||
|
|
||||||
|
assertThat( descriptor, instanceOf( StringTypeDescriptor.class ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRegisterJavaTypeDescriptorRegistry(){
|
||||||
|
final TypeConfiguration typeConfiguration = new TypeConfiguration();
|
||||||
|
final JavaTypeDescriptorRegistry registry = new JavaTypeDescriptorRegistry( typeConfiguration );
|
||||||
|
|
||||||
|
registry.addDescriptor( new CustomJavaTypeDescriptor() );
|
||||||
|
|
||||||
|
final JavaTypeDescriptor<?> descriptor = registry.getDescriptor( CustomType.class );
|
||||||
|
|
||||||
|
assertThat( descriptor, instanceOf( CustomJavaTypeDescriptor.class ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomType {}
|
||||||
|
|
||||||
|
public static class CustomJavaTypeDescriptor implements JavaTypeDescriptor<CustomType> {
|
||||||
|
@Override
|
||||||
|
public Class<CustomType> getJavaTypeClass() {
|
||||||
|
return CustomType.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutabilityPlan<CustomType> getMutabilityPlan() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SqlTypeDescriptor getJdbcRecommendedSqlType(SqlTypeDescriptorIndicators context) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Comparator<CustomType> getComparator() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int extractHashCode(CustomType value) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areEqual(CustomType one, CustomType another) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String extractLoggableRepresentation(CustomType value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(CustomType value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomType fromString(String string) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomType wrap(Object value, WrapperOptions options) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <X> X unwrap(CustomType value, Class<X> type, WrapperOptions options) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,15 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
*/
|
*/
|
||||||
package org.hibernate.type.descriptor.sql;
|
package org.hibernate.orm.test.type.descriptor.jdbc;
|
||||||
|
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
|
import org.hibernate.type.descriptor.sql.JdbcTypeJavaClassMappings;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
|
@ -1,116 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
||||||
*/
|
|
||||||
package org.hibernate.type;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import org.hibernate.type.descriptor.WrapperOptions;
|
|
||||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
|
||||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
|
||||||
import org.hibernate.type.descriptor.java.StringTypeDescriptor;
|
|
||||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
|
||||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Andrea Boriero
|
|
||||||
*/
|
|
||||||
public class JavaTypeDescriptorRegistryTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetJavaTypeDescriptorRegistry(){
|
|
||||||
TypeConfiguration typeConfiguration = new TypeConfiguration();
|
|
||||||
JavaTypeDescriptor<String> descriptor = typeConfiguration.getJavaTypeDescriptorRegistry()
|
|
||||||
.getDescriptor( String.class );
|
|
||||||
|
|
||||||
assertThat(descriptor, instanceOf(StringTypeDescriptor.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRegisterJavaTypeDescriptorRegistry(){
|
|
||||||
TypeConfiguration typeConfiguration = new TypeConfiguration();
|
|
||||||
typeConfiguration.getJavaTypeDescriptorRegistry().addDescriptor( new CustomJavaTypeDescriptor() );
|
|
||||||
JavaTypeDescriptor descriptor = typeConfiguration.getJavaTypeDescriptorRegistry()
|
|
||||||
.getDescriptor( CustomType.class );
|
|
||||||
|
|
||||||
assertThat(descriptor, instanceOf(CustomJavaTypeDescriptor.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddDirectlyToJavaTypeDescriptorRegistry(){
|
|
||||||
TypeConfiguration typeConfiguration = new TypeConfiguration();
|
|
||||||
org.hibernate.type.descriptor.java.JavaTypeDescriptorRegistry.INSTANCE.addDescriptor( new CustomJavaTypeDescriptor() );
|
|
||||||
JavaTypeDescriptor descriptor = typeConfiguration.getJavaTypeDescriptorRegistry()
|
|
||||||
.getDescriptor( CustomType.class );
|
|
||||||
|
|
||||||
assertThat(descriptor, instanceOf(CustomJavaTypeDescriptor.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CustomType {}
|
|
||||||
|
|
||||||
public class CustomJavaTypeDescriptor implements JavaTypeDescriptor{
|
|
||||||
@Override
|
|
||||||
public Class getJavaTypeClass() {
|
|
||||||
return CustomType.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MutabilityPlan getMutabilityPlan() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SqlTypeDescriptor getJdbcRecommendedSqlType(SqlTypeDescriptorIndicators context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Comparator getComparator() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int extractHashCode(Object value) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean areEqual(Object one, Object another) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String extractLoggableRepresentation(Object value) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString(Object value) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object fromString(String string) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object wrap(Object value, WrapperOptions options) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object unwrap(Object value, Class type, WrapperOptions options) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue