Search in sources :

Example 1 with UUIDJavaType

use of org.hibernate.type.descriptor.java.UUIDJavaType in project hibernate-orm by hibernate.

the class BasicTypeRegistryTest method testOverriding.

@Test
public void testOverriding() {
    TypeConfiguration typeConfiguration = new TypeConfiguration();
    BasicTypeRegistry registry = typeConfiguration.getBasicTypeRegistry();
    BasicType<?> uuidBinaryRegistration = registry.getRegisteredType("uuid-binary");
    assertTrue(uuidBinaryRegistration.getJavaTypeDescriptor() instanceof UUIDJavaType);
    assertTrue(uuidBinaryRegistration.getJdbcType() instanceof BinaryJdbcType);
    final BasicType<UUID> uuidRegistration = registry.getRegisteredType(UUID.class.getName());
    assertTrue(uuidRegistration.getJavaTypeDescriptor() instanceof UUIDJavaType);
    assertTrue(uuidRegistration.getJdbcType() instanceof ObjectJdbcType);
    final BasicType<?> override = new BasicTypeImpl<>(UUIDJavaType.INSTANCE, CharJdbcType.INSTANCE);
    registry.register(override, UUID.class.getName());
    final BasicType<Object> overrideRegistration = registry.getRegisteredType(UUID.class.getName());
    assertSame(override, overrideRegistration);
    assertNotSame(uuidBinaryRegistration, overrideRegistration);
    assertNotSame(uuidRegistration, overrideRegistration);
}
Also used : ObjectJdbcType(org.hibernate.type.descriptor.jdbc.ObjectJdbcType) BinaryJdbcType(org.hibernate.type.descriptor.jdbc.BinaryJdbcType) BasicTypeImpl(org.hibernate.type.internal.BasicTypeImpl) BasicTypeRegistry(org.hibernate.type.BasicTypeRegistry) TypeConfiguration(org.hibernate.type.spi.TypeConfiguration) UUID(java.util.UUID) UUIDJavaType(org.hibernate.type.descriptor.java.UUIDJavaType) Test(org.junit.Test)

Aggregations

UUID (java.util.UUID)1 BasicTypeRegistry (org.hibernate.type.BasicTypeRegistry)1 UUIDJavaType (org.hibernate.type.descriptor.java.UUIDJavaType)1 BinaryJdbcType (org.hibernate.type.descriptor.jdbc.BinaryJdbcType)1 ObjectJdbcType (org.hibernate.type.descriptor.jdbc.ObjectJdbcType)1 BasicTypeImpl (org.hibernate.type.internal.BasicTypeImpl)1 TypeConfiguration (org.hibernate.type.spi.TypeConfiguration)1 Test (org.junit.Test)1