Search in sources :

Example 96 with Query

use of org.hibernate.query.Query in project crypto-bot by jnidzwetzki.

the class TestPersistence method before.

/**
 * Delete old data from tables
 */
@Before
public void before() {
    try (final Session session = sessionFactory.openSession()) {
        session.beginTransaction();
        for (final String tablename : Arrays.asList("BitfinexOrder", "Trade")) {
            @SuppressWarnings("rawtypes") final Query query = session.createQuery("delete from " + tablename);
            query.executeUpdate();
        }
        session.close();
    }
}
Also used : Query(org.hibernate.query.Query) Session(org.hibernate.Session) Before(org.junit.Before)

Example 97 with Query

use of org.hibernate.query.Query in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateQuery.

@Test
public void testCreateQuery() {
    Query<?> query = (Query<?>) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Query.class }, new TestInvocationHandler());
    IQuery facade = facadeFactory.createQuery(query);
    Assert.assertSame(query, ((IFacade) facade).getTarget());
}
Also used : IQuery(org.jboss.tools.hibernate.runtime.spi.IQuery) IQuery(org.jboss.tools.hibernate.runtime.spi.IQuery) Query(org.hibernate.query.Query) 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) Test(org.junit.Test)

Example 98 with Query

use of org.hibernate.query.Query in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateQuery.

@Test
public void testCreateQuery() {
    Query<?> query = (Query<?>) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Query.class }, new TestInvocationHandler());
    IQuery facade = facadeFactory.createQuery(query);
    Assert.assertSame(query, ((IFacade) facade).getTarget());
}
Also used : IQuery(org.jboss.tools.hibernate.runtime.spi.IQuery) IQuery(org.jboss.tools.hibernate.runtime.spi.IQuery) Query(org.hibernate.query.Query) 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) Test(org.junit.Test)

Example 99 with Query

use of org.hibernate.query.Query in project jbosstools-hibernate by jbosstools.

the class QueryFacadeTest method setUp.

@Before
public void setUp() {
    Query<?> queryProxy = (Query<?>) Proxy.newProxyInstance(FACADE_FACTORY.getClassLoader(), new Class[] { Query.class }, new InvocationHandler() {

        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            methodName = method.getName();
            arguments = args;
            if ("list".equals(method.getName())) {
                return LIST;
            } else if ("getReturnAliases".equals(method.getName())) {
                return RETURN_ALIASES;
            } else if ("getReturnTypes".equals(method.getName())) {
                return RETURN_TYPES;
            } else
                return null;
        }
    });
    query = new AbstractQueryFacade(FACADE_FACTORY, queryProxy) {
    };
}
Also used : Query(org.hibernate.query.Query) AbstractQueryFacade(org.jboss.tools.hibernate.runtime.common.AbstractQueryFacade) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) Before(org.junit.Before)

Example 100 with Query

use of org.hibernate.query.Query in project jbosstools-hibernate by jbosstools.

the class QueryFacadeTest method setUp.

@Before
public void setUp() {
    Query<?> queryProxy = (Query<?>) Proxy.newProxyInstance(FACADE_FACTORY.getClassLoader(), new Class[] { Query.class }, new InvocationHandler() {

        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            methodName = method.getName();
            arguments = args;
            if ("list".equals(method.getName())) {
                return LIST;
            } else if ("getReturnAliases".equals(method.getName())) {
                return RETURN_ALIASES;
            } else if ("getReturnTypes".equals(method.getName())) {
                return RETURN_TYPES;
            } else
                return null;
        }
    });
    query = new AbstractQueryFacade(FACADE_FACTORY, queryProxy) {
    };
}
Also used : Query(org.hibernate.query.Query) AbstractQueryFacade(org.jboss.tools.hibernate.runtime.common.AbstractQueryFacade) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) Before(org.junit.Before)

Aggregations

Query (org.hibernate.query.Query)149 Test (org.junit.Test)46 Session (org.hibernate.Session)39 List (java.util.List)24 ArrayList (java.util.ArrayList)19 TestForIssue (org.hibernate.testing.TestForIssue)19 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)17 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)17 HashMap (java.util.HashMap)15 Map (java.util.Map)14 NativeQuery (org.hibernate.query.NativeQuery)14 AbstractJPATest (org.hibernate.test.jpa.AbstractJPATest)11 SessionFactory (org.hibernate.SessionFactory)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 SQLException (java.sql.SQLException)7 Collectors (java.util.stream.Collectors)7 RQuery (com.evolveum.midpoint.repo.sql.query.RQuery)6 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)6 Predicate (javax.persistence.criteria.Predicate)6 Root (javax.persistence.criteria.Root)6