use of org.nutz.dao.test.meta.Fighter in project nutz by nutzam.
the class ManyManyTest method update_links.
@Test
public void update_links() {
Base b = dao.fetchLinks(dao.fetch(Base.class, "blue"), "fighters");
int lv = b.getLevel();
b.setLevel(45);
for (Iterator<Fighter> it = b.getFighters().iterator(); it.hasNext(); ) {
it.next().setType(Fighter.TYPE.F22);
}
dao.updateLinks(b, "fighters");
b = dao.fetch(Base.class, "blue");
assertEquals(lv, b.getLevel());
b = dao.fetchLinks(dao.fetch(Base.class, "blue"), "fighters");
assertEquals(7, b.countFighter(Fighter.TYPE.F22));
}
use of org.nutz.dao.test.meta.Fighter in project nutz by nutzam.
the class ManyManyTest method update_with.
@Test
public void update_with() {
Base b = dao.fetchLinks(dao.fetch(Base.class, "blue"), "fighters");
b.setLevel(45);
for (Iterator<Fighter> it = b.getFighters().iterator(); it.hasNext(); ) {
it.next().setType(Fighter.TYPE.F22);
}
dao.updateWith(b, "fighters");
b = dao.fetch(Base.class, "blue");
assertEquals(45, b.getLevel());
b = dao.fetchLinks(dao.fetch(Base.class, "blue"), "fighters");
assertEquals(7, b.countFighter(Fighter.TYPE.F22));
}
use of org.nutz.dao.test.meta.Fighter 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));
}
});
}
Aggregations