コード例 #1
0
  // for some reason, this passes on local machine, but fails in the build server
  public void XtestInitialLoad() throws Exception {
    session.save(new Simple(1, "test1"));
    session.save(new Simple(2, "test2"));
    session.save(new SimpleBase(1, "test1"));
    session.save(new SimpleExtend(2, "test2", "test2ex"));
    session.save(new SimpleBase(3, "test3"));

    DataIterator iterator = sqlDataProvider.initialLoad();
    int count = 0;
    while (iterator.hasNext()) {
      Object val = iterator.next();
      session.delete(val);
      count++;
    }
    assertEquals(5, count);
    List existing = session.createQuery("from java.lang.Object").list();
    assertEquals(0, existing.size());
  }
コード例 #2
0
  public void XtestCountAndIterator() throws Exception {
    Transaction tx = session.beginTransaction();
    session.save(new Simple(1, "test1"));
    session.save(new Simple(2, "test2"));
    tx.commit();

    session.flush();
    session.close();
    SQLQuery<Simple> sql = new SQLQuery<Simple>(Simple.class, "id = ?");
    sql.setParameter(1, 1);
    DataIterator it = sqlDataProvider.iterator(sql);
    assertTrue(it.hasNext());
    assertEquals(1, ((Simple) it.next()).getId().intValue());

    it.close();
    sql.setParameter(1, 0);
    it = sqlDataProvider.iterator(sql);
    assertFalse(it.hasNext());
    it.close();
  }