use of org.hibernate.boot.internal.AttributeConverterDescriptorNonAutoApplicableImpl in project hibernate-orm by hibernate.
the class AttributeConverterTest method testBasicOperation.
@Test
public void testBasicOperation() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).buildMetadata();
SimpleValue simpleValue = new SimpleValue(metadata);
simpleValue.setJpaAttributeConverterDescriptor(new AttributeConverterDescriptorNonAutoApplicableImpl(new StringClobConverter()));
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());
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.internal.AttributeConverterDescriptorNonAutoApplicableImpl in project hibernate-orm by hibernate.
the class SimpleValue method setTypeName.
public void setTypeName(String typeName) {
if (typeName != null && typeName.startsWith(AttributeConverterTypeAdapter.NAME_PREFIX)) {
final String converterClassName = typeName.substring(AttributeConverterTypeAdapter.NAME_PREFIX.length());
final ClassLoaderService cls = getMetadata().getMetadataBuildingOptions().getServiceRegistry().getService(ClassLoaderService.class);
try {
final Class<AttributeConverter> converterClass = cls.classForName(converterClassName);
attributeConverterDescriptor = new AttributeConverterDescriptorNonAutoApplicableImpl(converterClass.newInstance());
return;
} catch (Exception e) {
log.logBadHbmAttributeConverterType(typeName, e.getMessage());
}
}
this.typeName = typeName;
}
Aggregations