Search in sources :

Example 1 with InstanceBasedConverterDescriptor

use of org.hibernate.boot.model.convert.internal.InstanceBasedConverterDescriptor in project hibernate-orm by hibernate.

the class AttributeConverterTest method testBasicOperation.

@Test
public void testBasicOperation() {
    SimpleValue simpleValue = new SimpleValue(new MetadataBuildingContextTestingImpl());
    simpleValue.setJpaAttributeConverterDescriptor(new InstanceBasedConverterDescriptor(new StringClobConverter(), new ClassmateContext()));
    simpleValue.setTypeUsingReflection(IrrelevantEntity.class.getName(), "name");
    Type type = simpleValue.getType();
    assertNotNull(type);
    if (!AttributeConverterTypeAdapter.class.isInstance(type)) {
        fail("AttributeConverter not applied");
    }
    AbstractStandardBasicType basicType = assertTyping(AbstractStandardBasicType.class, type);
    assertSame(StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor());
    assertEquals(Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType());
}
Also used : MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) BasicType(org.hibernate.type.BasicType) AbstractStandardBasicType(org.hibernate.type.AbstractStandardBasicType) Type(org.hibernate.type.Type) IrrelevantEntity(org.hibernate.IrrelevantEntity) AttributeConverterTypeAdapter(org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter) InstanceBasedConverterDescriptor(org.hibernate.boot.model.convert.internal.InstanceBasedConverterDescriptor) AbstractStandardBasicType(org.hibernate.type.AbstractStandardBasicType) SimpleValue(org.hibernate.mapping.SimpleValue) ClassmateContext(org.hibernate.boot.internal.ClassmateContext) Test(org.junit.Test)

Aggregations

IrrelevantEntity (org.hibernate.IrrelevantEntity)1 ClassmateContext (org.hibernate.boot.internal.ClassmateContext)1 InstanceBasedConverterDescriptor (org.hibernate.boot.model.convert.internal.InstanceBasedConverterDescriptor)1 SimpleValue (org.hibernate.mapping.SimpleValue)1 MetadataBuildingContextTestingImpl (org.hibernate.testing.boot.MetadataBuildingContextTestingImpl)1 AbstractStandardBasicType (org.hibernate.type.AbstractStandardBasicType)1 BasicType (org.hibernate.type.BasicType)1 Type (org.hibernate.type.Type)1 AttributeConverterTypeAdapter (org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter)1 Test (org.junit.Test)1