/** * 测试级联的更新操作 * * @throws SQLException */ @Test public void testRefUpdate() throws SQLException { System.out.println("=========== testRefUpdate Begin =========="); Transaction db = this.db.startTransaction(); Person p = new Person(); p.setId(2); p = db.load(p); // p.setSchoolId(0); p.setSchool(new School("华南大学")); p.setAge(123); db.updateCascade(p); db.rollback(true); System.out.println("=========== testRefUpdate End =========="); }
@Test public void testUpdateNormal() throws SQLException { Transaction db = this.db.startTransaction(); List<School> schools = db.selectAll(School.class); School s = schools.get(0); Person p = new Person(); p.setId(2); p = db.load(p); System.out.println(p); System.out.println(p.getSchoolId()); System.out.println(p.getSchool()); p.setSchool(s); db.update(p); db.rollback(true); }