use of org.jboss.tools.hibernate.runtime.spi.ISessionFactory in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testGetCollectionMetadata.
@Test
public void testGetCollectionMetadata() {
Configuration configuration = new Configuration();
configuration.addClass(Foo.class);
SessionFactory sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Metamodel metamodel = ((EntityManagerFactory) sessionFactory).getMetamodel();
CollectionMetadata collectionMetadata = (CollectionMetadata) ((MetamodelImplementor) metamodel).collectionPersister("org.jboss.tools.hibernate.runtime.v_5_3.internal.test.Foo.bars");
Assert.assertSame(collectionMetadata, ((IFacade) sessionFactoryFacade.getCollectionMetadata("org.jboss.tools.hibernate.runtime.v_5_3.internal.test.Foo.bars")).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.ISessionFactory in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testGetClassMetadata.
@Test
public void testGetClassMetadata() {
Configuration configuration = new Configuration();
configuration.addClass(Foo.class);
SessionFactory sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
Metamodel metamodel = ((EntityManagerFactory) sessionFactory).getMetamodel();
ClassMetadata classMetadata = (ClassMetadata) ((MetamodelImplementor) metamodel).entityPersister(Foo.class);
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Assert.assertSame(classMetadata, ((IFacade) sessionFactoryFacade.getClassMetadata(Foo.class)).getTarget());
Assert.assertSame(classMetadata, ((IFacade) sessionFactoryFacade.getClassMetadata("org.jboss.tools.hibernate.runtime.v_5_3.internal.test.Foo")).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.ISessionFactory in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testGetAllClassMetadata.
@Test
public void testGetAllClassMetadata() throws Exception {
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Assert.assertTrue(sessionFactoryFacade.getAllClassMetadata().isEmpty());
sessionFactory.close();
configuration.addClass(Foo.class);
sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Map<String, IClassMetadata> allClassMetaData = sessionFactoryFacade.getAllClassMetadata();
Assert.assertNotNull(allClassMetaData.get("org.jboss.tools.hibernate.runtime.v_5_3.internal.test.Foo"));
}
use of org.jboss.tools.hibernate.runtime.spi.ISessionFactory in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testGetAllCollectionMetadata.
@Test
public void testGetAllCollectionMetadata() {
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Assert.assertTrue(sessionFactoryFacade.getAllCollectionMetadata().isEmpty());
sessionFactory.close();
configuration.addClass(Foo.class);
sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Map<String, ICollectionMetadata> allCollectionMetaData = sessionFactoryFacade.getAllCollectionMetadata();
Assert.assertNotNull(allCollectionMetaData.get("org.jboss.tools.hibernate.runtime.v_5_3.internal.test.Foo.bars"));
}
use of org.jboss.tools.hibernate.runtime.spi.ISessionFactory in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testClose.
@Test
public void testClose() {
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
sessionFactory.openSession();
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Assert.assertFalse(sessionFactory.isClosed());
sessionFactoryFacade.close();
Assert.assertTrue(sessionFactory.isClosed());
}
Aggregations