use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class MetadataTest method testBuildingMetamodelWithParameterizedCollection.
@Test
@SuppressWarnings({ "unchecked" })
public void testBuildingMetamodelWithParameterizedCollection() {
Metadata metadata = new MetadataSources().addAnnotatedClass(WithGenericCollection.class).buildMetadata();
SessionFactoryImplementor sfi = (SessionFactoryImplementor) metadata.buildSessionFactory();
MetamodelImpl metamodel = new MetamodelImpl(sfi);
metamodel.initialize((MetadataImplementor) metadata, JpaMetaModelPopulationSetting.IGNORE_UNSUPPORTED);
sfi.close();
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class GetAndIsVariantGetterTest method testAnnotationsFieldAccess.
@Test
@TestForIssue(jiraKey = "HHH-10309")
public void testAnnotationsFieldAccess() {
// this one should be ok because the AccessType is FIELD
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(AnotherEntity.class).buildMetadata();
assertNotNull(metadata.getEntityBinding(AnotherEntity.class.getName()).getIdentifier());
assertNotNull(metadata.getEntityBinding(AnotherEntity.class.getName()).getIdentifierProperty());
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class CollectionAsBasicTest method testCollectionAsBasic.
@Test
public void testCollectionAsBasic() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Post.class).getMetadataBuilder().applyBasicType(new DelimitedStringsType()).build();
PersistentClass postBinding = metadata.getEntityBinding(Post.class.getName());
Property tagsAttribute = postBinding.getProperty("tags");
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class EnumeratedWithMappedSuperclassTest method testHHH10128.
@Test
public void testHHH10128() {
final Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Entity.class).addAnnotatedClass(DescriptionEntity.class).addAnnotatedClass(AddressLevel.class).buildMetadata();
final PersistentClass addressLevelBinding = metadata.getEntityBinding(AddressLevel.class.getName());
final Property natureProperty = addressLevelBinding.getProperty("nature");
CustomType customType = assertTyping(CustomType.class, natureProperty.getType());
EnumType enumType = assertTyping(EnumType.class, customType.getUserType());
assertEquals(Types.VARCHAR, enumType.sqlTypes()[0]);
SessionFactoryImplementor sf = (SessionFactoryImplementor) metadata.buildSessionFactory();
try {
EntityPersister p = sf.getEntityPersister(AddressLevel.class.getName());
CustomType runtimeType = assertTyping(CustomType.class, p.getPropertyType("nature"));
EnumType runtimeEnumType = assertTyping(EnumType.class, runtimeType.getUserType());
assertEquals(Types.VARCHAR, runtimeEnumType.sqlTypes()[0]);
} finally {
sf.close();
}
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class OrmXmlEnumTypeTest method testOrmXmlDefinedEnumType.
@Test
public void testOrmXmlDefinedEnumType() {
StandardServiceRegistry ssr = ServiceRegistryBuilder.buildServiceRegistry();
try {
MetadataSources ms = new MetadataSources(ssr);
ms.addResource("org/hibernate/test/annotations/enumerated/ormXml/orm.xml");
Metadata metadata = ms.buildMetadata();
Type bindingPropertyType = metadata.getEntityBinding(BookWithOrmEnum.class.getName()).getProperty("bindingStringEnum").getType();
CustomType customType = ExtraAssertions.assertTyping(CustomType.class, bindingPropertyType);
EnumType enumType = ExtraAssertions.assertTyping(EnumType.class, customType.getUserType());
assertFalse(enumType.isOrdinal());
} finally {
ServiceRegistryBuilder.destroy(ssr);
}
}
Aggregations