use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class ParameterizedAttributeConverterParameterTypeTest method testNestedTypeParameterAutoApplication.
@Test
@TestForIssue(jiraKey = "HHH-10050")
public void testNestedTypeParameterAutoApplication() {
final Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(SampleEntity.class).getMetadataBuilder().applyAttributeConverter(IntegerListConverter.class).applyAttributeConverter(StringListConverter.class).build();
// lets make sure the auto-apply converters were applied properly...
PersistentClass pc = metadata.getEntityBinding(SampleEntity.class.getName());
{
Property prop = pc.getProperty("someStrings");
AttributeConverterTypeAdapter type = assertTyping(AttributeConverterTypeAdapter.class, prop.getType());
assertTyping(StringListConverter.class, type.getAttributeConverter());
}
{
Property prop = pc.getProperty("someIntegers");
AttributeConverterTypeAdapter type = assertTyping(AttributeConverterTypeAdapter.class, prop.getType());
assertTyping(IntegerListConverter.class, type.getAttributeConverter());
}
}
use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class SimpleXmlOverriddenTest method baseline.
/**
* A baseline test, with an explicit @Convert annotation that should be in effect
*/
@Test
public void baseline() {
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(TheEntity.class).buildMetadata();
PersistentClass pc = metadata.getEntityBinding(TheEntity.class.getName());
Type type = pc.getProperty("it").getType();
AttributeConverterTypeAdapter adapter = assertTyping(AttributeConverterTypeAdapter.class, type);
assertTyping(SillyStringConverter.class, adapter.getAttributeConverter());
}
use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class SimpleXmlOverriddenTest method testDefinitionAtAttributeLevel.
/**
* Test outcome of applying overrides via orm.xml, specifically at the attribute level
*/
@Test
public void testDefinitionAtAttributeLevel() {
// NOTE : simple-override.xml applied disable-conversion="true" at the attribute-level
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(TheEntity.class).addResource("org/hibernate/test/converter/simple-override.xml").buildMetadata();
PersistentClass pc = metadata.getEntityBinding(TheEntity.class.getName());
Type type = pc.getProperty("it").getType();
assertTyping(StringType.class, type);
}
use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class InvalidEnumeratedJavaTypeTest method testInvalidMapping.
@Test
public void testInvalidMapping() {
MetadataSources metadataSources = new MetadataSources().addAnnotatedClass(TheEntity.class);
try {
metadataSources.buildMetadata();
fail("Was expecting failure");
} catch (AnnotationException ignore) {
} finally {
ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
}
}
}
use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class ExtendsTest method testMissingSuper.
@Test
public void testMissingSuper() {
try {
Metadata metadata = new MetadataSources(serviceRegistry).addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml").addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml").buildMetadata();
fail("Should not be able to build sessionFactory without a Person");
} catch (HibernateException e) {
}
}
Aggregations