clean up remaining test suite failures
This commit is contained in:
parent
4e5a28deaa
commit
1ad9133871
|
@ -46,8 +46,10 @@ public class UserTypeJavaTypeWrapper<J> implements BasicJavaType<J> {
|
||||||
|
|
||||||
if ( resolvedMutabilityPlan == null ) {
|
if ( resolvedMutabilityPlan == null ) {
|
||||||
final Class<J> jClass = userType.returnedClass();
|
final Class<J> jClass = userType.returnedClass();
|
||||||
if ( jClass.getAnnotation( Immutable.class ) != null ) {
|
if ( jClass != null ) {
|
||||||
resolvedMutabilityPlan = ImmutableMutabilityPlan.instance();
|
if ( jClass.getAnnotation( Immutable.class ) != null ) {
|
||||||
|
resolvedMutabilityPlan = ImmutableMutabilityPlan.instance();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,14 +59,16 @@ public class UserTypeSqlTypeAdapter<J> implements JdbcType {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
public <X> ValueBinder<X> getBinder(JavaType<X> javaTypeDescriptor) {
|
public <X> ValueBinder<X> getBinder(JavaType<X> javaTypeDescriptor) {
|
||||||
assert jtd.getJavaTypeClass().isAssignableFrom( javaTypeDescriptor.getJavaTypeClass() );
|
assert javaTypeDescriptor.getJavaTypeClass() == null
|
||||||
|
|| jtd.getJavaTypeClass().isAssignableFrom( javaTypeDescriptor.getJavaTypeClass() );
|
||||||
return (ValueBinder<X>) valueBinder;
|
return (ValueBinder<X>) valueBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
public <X> ValueExtractor<X> getExtractor(JavaType<X> javaTypeDescriptor) {
|
public <X> ValueExtractor<X> getExtractor(JavaType<X> javaTypeDescriptor) {
|
||||||
assert javaTypeDescriptor.getJavaTypeClass().isAssignableFrom( jtd.getJavaTypeClass() );
|
assert javaTypeDescriptor.getJavaTypeClass() == null
|
||||||
|
|| javaTypeDescriptor.getJavaTypeClass().isAssignableFrom( jtd.getJavaTypeClass() );
|
||||||
return (ValueExtractor<X>) valueExtractor;
|
return (ValueExtractor<X>) valueExtractor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* 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.test.type;
|
package org.hibernate.orm.test.type;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
@ -22,6 +22,7 @@ import org.hibernate.type.descriptor.java.StringJavaTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor;
|
import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.jdbc.BinaryJdbcType;
|
import org.hibernate.type.descriptor.jdbc.BinaryJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.CharJdbcType;
|
import org.hibernate.type.descriptor.jdbc.CharJdbcType;
|
||||||
|
import org.hibernate.type.descriptor.jdbc.ObjectJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.VarcharJdbcType;
|
import org.hibernate.type.descriptor.jdbc.VarcharJdbcType;
|
||||||
import org.hibernate.type.internal.BasicTypeImpl;
|
import org.hibernate.type.internal.BasicTypeImpl;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
@ -30,6 +31,7 @@ import org.hibernate.usertype.UserType;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.Assert.assertNotSame;
|
||||||
|
@ -46,15 +48,22 @@ public class BasicTypeRegistryTest extends BaseUnitTestCase {
|
||||||
TypeConfiguration typeConfiguration = new TypeConfiguration();
|
TypeConfiguration typeConfiguration = new TypeConfiguration();
|
||||||
BasicTypeRegistry registry = typeConfiguration.getBasicTypeRegistry();
|
BasicTypeRegistry registry = typeConfiguration.getBasicTypeRegistry();
|
||||||
|
|
||||||
BasicType<?> type = registry.getRegisteredType( "uuid-binary" );
|
BasicType<?> uuidBinaryRegistration = registry.getRegisteredType( "uuid-binary" );
|
||||||
assertTrue( type.getJavaTypeDescriptor() instanceof UUIDJavaTypeDescriptor );
|
assertTrue( uuidBinaryRegistration.getJavaTypeDescriptor() instanceof UUIDJavaTypeDescriptor );
|
||||||
assertTrue( type.getJdbcTypeDescriptor() instanceof BinaryJdbcType );
|
assertTrue( uuidBinaryRegistration.getJdbcTypeDescriptor() instanceof BinaryJdbcType );
|
||||||
assertSame( type, registry.getRegisteredType( UUID.class.getName() ) );
|
|
||||||
|
|
||||||
BasicType<?> override = new BasicTypeImpl<>( UUIDJavaTypeDescriptor.INSTANCE, CharJdbcType.INSTANCE );
|
final BasicType<UUID> uuidRegistration = registry.getRegisteredType( UUID.class.getName() );
|
||||||
|
assertTrue( uuidRegistration.getJavaTypeDescriptor() instanceof UUIDJavaTypeDescriptor );
|
||||||
|
assertTrue( uuidRegistration.getJdbcTypeDescriptor() instanceof ObjectJdbcType );
|
||||||
|
|
||||||
|
final BasicType<?> override = new BasicTypeImpl<>( UUIDJavaTypeDescriptor.INSTANCE, CharJdbcType.INSTANCE );
|
||||||
registry.register( override, UUID.class.getName() );
|
registry.register( override, UUID.class.getName() );
|
||||||
assertNotSame( type, registry.getRegisteredType( UUID.class.getName() ) );
|
|
||||||
assertSame( override, registry.getRegisteredType( UUID.class.getName() ) );
|
final BasicType<Object> overrideRegistration = registry.getRegisteredType( UUID.class.getName() );
|
||||||
|
|
||||||
|
assertSame( override, overrideRegistration );
|
||||||
|
assertNotSame( uuidBinaryRegistration, overrideRegistration );
|
||||||
|
assertNotSame( uuidRegistration, overrideRegistration );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -83,8 +92,9 @@ public class BasicTypeRegistryTest extends BaseUnitTestCase {
|
||||||
assertEquals( TotallyIrrelevantUserType.class, ( (CustomType<Object>) customType ).getUserType().getClass() );
|
assertEquals( TotallyIrrelevantUserType.class, ( (CustomType<Object>) customType ).getUserType().getClass() );
|
||||||
|
|
||||||
BasicType<?> type = registry.getRegisteredType( UUID.class.getName() );
|
BasicType<?> type = registry.getRegisteredType( UUID.class.getName() );
|
||||||
assertTrue( type.getJavaTypeDescriptor() instanceof UUIDJavaTypeDescriptor );
|
assertThat( type.getJavaTypeDescriptor() ).isInstanceOf( UUIDJavaTypeDescriptor.class );
|
||||||
assertTrue( type.getJdbcTypeDescriptor() instanceof BinaryJdbcType );
|
assertThat( type.getJdbcTypeDescriptor() ).isInstanceOf( ObjectJdbcType.class );
|
||||||
|
|
||||||
registry.register( new TotallyIrrelevantUserType(), UUID.class.getName() );
|
registry.register( new TotallyIrrelevantUserType(), UUID.class.getName() );
|
||||||
assertNotSame( type, registry.getRegisteredType( UUID.class.getName() ) );
|
assertNotSame( type, registry.getRegisteredType( UUID.class.getName() ) );
|
||||||
assertEquals( CustomType.class, registry.getRegisteredType( UUID.class.getName() ).getClass() );
|
assertEquals( CustomType.class, registry.getRegisteredType( UUID.class.getName() ).getClass() );
|
Loading…
Reference in New Issue