use of org.hibernate.type.BasicType in project hibernate-orm by hibernate.
the class AttributeConverterTest method testBasicOrmXmlConverterApplication.
@Test
@TestForIssue(jiraKey = "HHH-8462")
public void testBasicOrmXmlConverterApplication() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(Tester.class).addURL(ConfigHelper.findAsResource("org/hibernate/test/converter/orm.xml")).getMetadataBuilder().build();
PersistentClass tester = metadata.getEntityBinding(Tester.class.getName());
Property nameProp = tester.getProperty("name");
SimpleValue nameValue = (SimpleValue) nameProp.getValue();
Type type = nameValue.getType();
assertNotNull(type);
if (!AttributeConverterTypeAdapter.class.isInstance(type)) {
fail("AttributeConverter not applied");
}
AttributeConverterTypeAdapter basicType = assertTyping(AttributeConverterTypeAdapter.class, type);
assertSame(StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor());
assertEquals(Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType());
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.type.BasicType in project hibernate-orm by hibernate.
the class AttributeConverterTest method testBasicConverterDisableApplication.
@Test
public void testBasicConverterDisableApplication() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(Tester2.class).getMetadataBuilder().applyAttributeConverter(StringClobConverter.class, true).build();
PersistentClass tester = metadata.getEntityBinding(Tester2.class.getName());
Property nameProp = tester.getProperty("name");
SimpleValue nameValue = (SimpleValue) nameProp.getValue();
Type type = nameValue.getType();
assertNotNull(type);
if (AttributeConverterTypeAdapter.class.isInstance(type)) {
fail("AttributeConverter applied (should not have been)");
}
AbstractStandardBasicType basicType = assertTyping(AbstractStandardBasicType.class, type);
assertSame(StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor());
assertEquals(Types.VARCHAR, basicType.getSqlTypeDescriptor().getSqlType());
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.type.BasicType in project hibernate-orm by hibernate.
the class AttributeConverterTest method testBasicConverterApplication.
@Test
public void testBasicConverterApplication() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(Tester.class).getMetadataBuilder().applyAttributeConverter(StringClobConverter.class, true).build();
PersistentClass tester = metadata.getEntityBinding(Tester.class.getName());
Property nameProp = tester.getProperty("name");
SimpleValue nameValue = (SimpleValue) nameProp.getValue();
Type type = nameValue.getType();
assertNotNull(type);
assertTyping(BasicType.class, 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);
}
}
Aggregations