Search in sources :

Example 1 with ISession

use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.

the class HibernateExtension method executeHQLQuery.

public QueryPage executeHQLQuery(final String hql, final QueryInputModel queryParameters) {
    return (QueryPage) execute(new Command() {

        public Object execute() {
            ISession session = sessionFactory.openSession();
            QueryPage qp = new HQLQueryPage(HibernateExtension.this, hql, queryParameters);
            qp.setSession(session);
            return qp;
        }
    });
}
Also used : ISession(org.jboss.tools.hibernate.runtime.spi.ISession) Command(org.hibernate.console.execution.ExecutionContext.Command) QueryPage(org.hibernate.console.QueryPage)

Example 2 with ISession

use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateSession.

@Test
public void testCreateSession() {
    Session session = (Session) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Session.class }, new TestInvocationHandler());
    ISession facade = facadeFactory.createSession(session);
    Assert.assertSame(session, ((IFacade) facade).getTarget());
}
Also used : ISession(org.jboss.tools.hibernate.runtime.spi.ISession) PersistentClass(org.hibernate.mapping.PersistentClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) ISession(org.jboss.tools.hibernate.runtime.spi.ISession) Session(org.hibernate.Session) Test(org.junit.Test)

Example 3 with ISession

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);
}
Also used : ISession(org.jboss.tools.hibernate.runtime.spi.ISession) SessionImplementor(org.hibernate.engine.SessionImplementor) RootClass(org.hibernate.mapping.RootClass) PersistentClass(org.hibernate.mapping.PersistentClass) Method(java.lang.reflect.Method) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) InvocationHandler(java.lang.reflect.InvocationHandler) Test(org.junit.Test)

Example 4 with ISession

use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateSession.

@Test
public void testCreateSession() {
    Session session = (Session) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Session.class }, new TestInvocationHandler());
    ISession facade = facadeFactory.createSession(session);
    Assert.assertSame(session, ((IFacade) facade).getTarget());
}
Also used : ISession(org.jboss.tools.hibernate.runtime.spi.ISession) PersistentClass(org.hibernate.mapping.PersistentClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) ISession(org.jboss.tools.hibernate.runtime.spi.ISession) Session(org.hibernate.Session) Test(org.junit.Test)

Example 5 with ISession

use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateSession.

@Test
public void testCreateSession() {
    Session session = (Session) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Session.class }, new TestInvocationHandler());
    ISession facade = facadeFactory.createSession(session);
    Assert.assertSame(session, ((IFacade) facade).getTarget());
}
Also used : ISession(org.jboss.tools.hibernate.runtime.spi.ISession) PersistentClass(org.hibernate.mapping.PersistentClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) ISession(org.jboss.tools.hibernate.runtime.spi.ISession) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

ISession (org.jboss.tools.hibernate.runtime.spi.ISession)27 Test (org.junit.Test)24 Session (org.hibernate.Session)16 PersistentClass (org.hibernate.mapping.PersistentClass)16 RootClass (org.hibernate.mapping.RootClass)16 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)9 InvocationHandler (java.lang.reflect.InvocationHandler)8 Method (java.lang.reflect.Method)8 SessionFactory (org.hibernate.SessionFactory)8 Configuration (org.hibernate.cfg.Configuration)8 POJOClass (org.hibernate.tool.hbm2x.pojo.POJOClass)8 IPOJOClass (org.jboss.tools.hibernate.runtime.spi.IPOJOClass)8 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)8 ISessionFactory (org.jboss.tools.hibernate.runtime.spi.ISessionFactory)8 SessionImplementor (org.hibernate.engine.spi.SessionImplementor)6 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)5 QueryPage (org.hibernate.console.QueryPage)2 Command (org.hibernate.console.execution.ExecutionContext.Command)2 SessionImplementor (org.hibernate.engine.SessionImplementor)2 ServiceRegistry (org.hibernate.service.ServiceRegistry)1