use of org.jboss.tools.hibernate.runtime.spi.ISession 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.ISession in project jbosstools-hibernate by jbosstools.
the class ClassMetadataFacadeTest method testGetIdentifier.
@Test
public void testGetIdentifier() {
ClassLoader cl = FACADE_FACTORY.getClassLoader();
final SessionImplementor sessionTarget = (SessionImplementor) Proxy.newProxyInstance(cl, new Class[] { SessionImplementor.class }, new TestInvocationHandler());
ISession session = (ISession) Proxy.newProxyInstance(cl, new Class[] { ISession.class, IFacade.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return sessionTarget;
}
});
Object object = Integer.MAX_VALUE;
Assert.assertSame(object, classMetadata.getIdentifier(object, session));
Assert.assertEquals("getIdentifier", methodName);
Assert.assertArrayEquals(new Object[] { object, sessionTarget }, arguments);
}
use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.
the class ClassMetadataFacadeTest method testGetIdentifier.
@Test
public void testGetIdentifier() {
ClassLoader cl = FACADE_FACTORY.getClassLoader();
final SessionImplementor sessionTarget = (SessionImplementor) Proxy.newProxyInstance(cl, new Class[] { SessionImplementor.class }, new TestInvocationHandler());
ISession session = (ISession) Proxy.newProxyInstance(cl, new Class[] { ISession.class, IFacade.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return sessionTarget;
}
});
Object object = Integer.MAX_VALUE;
Assert.assertSame(object, classMetadata.getIdentifier(object, session));
Assert.assertEquals("getIdentifier", methodName);
Assert.assertArrayEquals(new Object[] { object, sessionTarget }, arguments);
}
use of org.jboss.tools.hibernate.runtime.spi.ISession 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.ISession in project jbosstools-hibernate by jbosstools.
the class AbstractFacadeFactory method createFullTextSession.
@Override
public IFullTextSession createFullTextSession(ISessionFactory sessionFactory) {
ISession session = sessionFactory.openSession();
Object targetSession = ((IFacade) session).getTarget();
Object targetFullTextSession = Util.invokeMethod(getSearchClass(), "getFullTextSession", new Class[] { getSessionClass() }, new Object[] { targetSession });
return new AbstractFullTextSessionFacade(this, targetFullTextSession) {
};
}
Aggregations