use of org.nutz.dao.test.meta.Base 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.Base 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.Base in project nutz by nutzam.
the class ManyManyTest method delete_links_partly.
@Test
public void delete_links_partly() {
Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "fighters");
b.getFighters().remove(0);
b.getFighters().remove(0);
dao.deleteLinks(b, "fighters");
assertEquals(9, dao.count(Fighter.class));
}
use of org.nutz.dao.test.meta.Base in project nutz by nutzam.
the class ManyManyTest method delete_links.
@Test
public void delete_links() {
Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "fighters");
dao.deleteLinks(b, "fighters");
assertEquals(7, dao.count(Fighter.class));
assertEquals(7, dao.count(((ManyManyLinkField) dao.getEntity(Base.class).getLinkFields("fighters").get(0)).getRelationName()));
}
use of org.nutz.dao.test.meta.Base in project nutz by nutzam.
the class ManyTest method delete_with_partly.
@Test
public void delete_with_partly() {
Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "platoons");
b.getPlatoons().remove("C");
dao.deleteWith(b, "platoons");
assertEquals(4, dao.count(Platoon.class));
assertEquals(1, dao.count(Base.class));
}