use of org.jboss.tools.hibernate.runtime.spi.ISessionFactory in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateSessionFactory.
@Test
public void testCreateSessionFactory() {
SessionFactory sessionFactory = (SessionFactory) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { SessionFactory.class }, new TestInvocationHandler());
ISessionFactory facade = facadeFactory.createSessionFactory(sessionFactory);
Assert.assertSame(sessionFactory, ((IFacade) facade).getTarget());
Assert.assertTrue(SessionFactoryFacadeImpl.class.isInstance(facade));
}
use of org.jboss.tools.hibernate.runtime.spi.ISessionFactory in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testOpenSession.
@Test
public void testOpenSession() {
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
ISession sessionFacade = sessionFactoryFacade.openSession();
Session session = (Session) ((IFacade) sessionFacade).getTarget();
Assert.assertSame(sessionFactory, session.getSessionFactory());
}
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_1.internal.test.Foo"));
}
use of org.jboss.tools.hibernate.runtime.spi.ISessionFactory in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testBuildSessionFactory.
@Test
public void testBuildSessionFactory() throws Throwable {
ISessionFactory sessionFactoryFacade = configurationFacade.buildSessionFactory();
Assert.assertNotNull(sessionFactoryFacade);
Object sessionFactory = ((IFacade) sessionFactoryFacade).getTarget();
Assert.assertNotNull(sessionFactory);
Assert.assertTrue(sessionFactory instanceof SessionFactory);
}
use of org.jboss.tools.hibernate.runtime.spi.ISessionFactory in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewHQLQueryPlan.
@Test
public void testNewHQLQueryPlan() throws Exception {
IConfiguration configuration = service.newDefaultConfiguration();
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
File testFile = File.createTempFile("test", "tmp");
testFile.deleteOnExit();
FileWriter fileWriter = new FileWriter(testFile);
fileWriter.write(TEST_HBM_STRING);
fileWriter.close();
configuration.addFile(testFile);
ISessionFactory sfi = configuration.buildSessionFactory();
IHQLQueryPlan queryPlan = service.newHQLQueryPlan("from ServiceImplTest$Foo", true, sfi);
Assert.assertNotNull(queryPlan);
Object target = ((IFacade) queryPlan).getTarget();
Assert.assertNotNull(target);
Assert.assertTrue(target instanceof HQLQueryPlan);
}
Aggregations