use of org.nutz.dao.DaoException in project nutz by nutzam.
the class BatchTransTest method try_insert_static_objects_by_many_many.
@Test
public void try_insert_static_objects_by_many_many() {
pojos.init();
final Base b = Base.make("B");
b.setFighters(new ArrayList<Fighter>());
TableName.run(1, new Atom() {
public void run() {
Trans.exec(new Atom() {
public void run() {
dao.insert(Country.make("A"));
try {
dao.insert(Country.make("A"));
} catch (DaoException e) {
}
dao.insert(Country.make("C"));
dao.insert(Country.make("D"));
}
});
assertEquals(3, dao.count(Country.class));
}
});
}
use of org.nutz.dao.DaoException in project nutz by nutzam.
the class SimpleDaoTest method run_2_sqls_with_error.
@Test
public void run_2_sqls_with_error() {
assertEquals(0, dao.count(Pet.class));
Sql sql1 = Sqls.create("INSERT INTO t_pet (name) VALUES ('A')");
Sql sql2 = Sqls.create("INSERT INTO t_pet (nocol) VALUES ('B')");
try {
dao.execute(sql1, sql2);
fail();
} catch (DaoException e) {
}
assertEquals(0, dao.count(Pet.class));
}
Aggregations