Search in sources :

Example 1 with StateProvince

use of org.hibernate.test.hql.StateProvince in project hibernate-orm by hibernate.

the class LongInElementsTest method testLongInElementsByHQL.

@Test
@TestForIssue(jiraKey = "HHH-2166")
@SkipForDialect(value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class, SybaseDialect.class }, comment = "this test fails on oracle and ms sql server, for more info, see HHH-1123")
public void testLongInElementsByHQL() {
    Session session = openSession();
    Transaction t = session.beginTransaction();
    StateProvince beijing = new StateProvince();
    beijing.setIsoCode("100089");
    beijing.setName("beijing");
    session.persist(beijing);
    session.flush();
    session.clear();
    Query query = session.createQuery("from org.hibernate.test.hql.StateProvince sp where sp.id in ( :idList )");
    query.setParameterList("idList", createLotsOfElements());
    List list = query.list();
    session.flush();
    session.clear();
    assertEquals(1, list.size());
    session.delete(beijing);
    t.commit();
    session.close();
}
Also used : Transaction(org.hibernate.Transaction) Query(org.hibernate.Query) StateProvince(org.hibernate.test.hql.StateProvince) ArrayList(java.util.ArrayList) List(java.util.List) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 2 with StateProvince

use of org.hibernate.test.hql.StateProvince in project hibernate-orm by hibernate.

the class LongInElementsTest method testLongInElementsByCriteria.

@Test
@TestForIssue(jiraKey = "HHH-2166")
@SkipForDialect(value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class, SybaseDialect.class }, comment = "this test fails on oracle and ms sql server, for more info, see HHH-1123")
public void testLongInElementsByCriteria() {
    Session session = openSession();
    Transaction t = session.beginTransaction();
    StateProvince beijing = new StateProvince();
    beijing.setIsoCode("100089");
    beijing.setName("beijing");
    session.persist(beijing);
    session.flush();
    session.clear();
    Criteria criteria = session.createCriteria(StateProvince.class);
    criteria.add(Restrictions.in("id", createLotsOfElements()));
    List list = criteria.list();
    session.flush();
    session.clear();
    assertEquals(1, list.size());
    session.delete(beijing);
    t.commit();
    session.close();
}
Also used : Transaction(org.hibernate.Transaction) StateProvince(org.hibernate.test.hql.StateProvince) ArrayList(java.util.ArrayList) List(java.util.List) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 Session (org.hibernate.Session)2 Transaction (org.hibernate.Transaction)2 StateProvince (org.hibernate.test.hql.StateProvince)2 SkipForDialect (org.hibernate.testing.SkipForDialect)2 TestForIssue (org.hibernate.testing.TestForIssue)2 Test (org.junit.Test)2 Criteria (org.hibernate.Criteria)1 Query (org.hibernate.Query)1