Search in sources :

Example 1 with CompositeCustomType

use of org.hibernate.type.CompositeCustomType in project hibernate-orm by hibernate.

the class BasicTypeRegistryTest method testRegisteringUserTypes.

@Test
public void testRegisteringUserTypes() {
    BasicTypeRegistry registry = new BasicTypeRegistry();
    registry.register(new TotallyIrrelevantUserType(), new String[] { "key" });
    BasicType type = registry.getRegisteredType("key");
    assertNotNull(type);
    assertEquals(CustomType.class, type.getClass());
    assertEquals(TotallyIrrelevantUserType.class, ((CustomType) type).getUserType().getClass());
    registry.register(new TotallyIrrelevantCompositeUserType(), new String[] { "key" });
    type = registry.getRegisteredType("key");
    assertNotNull(type);
    assertEquals(CompositeCustomType.class, type.getClass());
    assertEquals(TotallyIrrelevantCompositeUserType.class, ((CompositeCustomType) type).getUserType().getClass());
    type = registry.getRegisteredType(UUID.class.getName());
    assertSame(UUIDBinaryType.INSTANCE, type);
    registry.register(new TotallyIrrelevantUserType(), new String[] { UUID.class.getName() });
    type = registry.getRegisteredType(UUID.class.getName());
    assertNotSame(UUIDBinaryType.INSTANCE, type);
    assertEquals(CustomType.class, type.getClass());
}
Also used : CustomType(org.hibernate.type.CustomType) CompositeCustomType(org.hibernate.type.CompositeCustomType) BasicType(org.hibernate.type.BasicType) AbstractSingleColumnStandardBasicType(org.hibernate.type.AbstractSingleColumnStandardBasicType) CompositeCustomType(org.hibernate.type.CompositeCustomType) BasicTypeRegistry(org.hibernate.type.BasicTypeRegistry) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

UUID (java.util.UUID)1 AbstractSingleColumnStandardBasicType (org.hibernate.type.AbstractSingleColumnStandardBasicType)1 BasicType (org.hibernate.type.BasicType)1 BasicTypeRegistry (org.hibernate.type.BasicTypeRegistry)1 CompositeCustomType (org.hibernate.type.CompositeCustomType)1 CustomType (org.hibernate.type.CustomType)1 Test (org.junit.Test)1