Created
January 28, 2012 14:39
-
-
Save wendal/1694549 to your computer and use it in GitHub Desktop.
Nutz_fastinsert_rollback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For github issue 131 | |
@Test | |
public void test_fastInsert_rollback() { | |
dao.create(Pet.class, true); | |
final List<Pet> pets = new ArrayList<Pet>(); | |
for (int i = 0; i < 100; i++) { | |
Pet u = new Pet(); | |
u.setName("XXXX" + i); | |
pets.add(u); | |
} | |
try { | |
Trans.exec(new Molecule<Object>() { | |
@Override | |
public void run() { | |
dao.fastInsert(pets); | |
throw new RuntimeException(); | |
} | |
}); | |
} catch (Throwable e) { | |
e.printStackTrace(); | |
} | |
assertEquals(0, dao.count(Pet.class)); | |
} | |
//For github issue 131 | |
@Test | |
public void test_fastInsert_rollback_jdbc() { | |
dao.create(Pet.class, true); | |
try { | |
Trans.exec(new Molecule<Object>() { | |
@Override | |
public void run() { | |
dao.run(new ConnCallback() { | |
@Override | |
public void invoke(Connection conn) throws Exception { | |
PreparedStatement ps = conn.prepareStatement("INSERT INTO t_pet(name) VALUES(?)"); | |
for (int i = 0; i < 100; i++) { | |
ps.setString(1, "XXXXX" + i); | |
ps.addBatch(); | |
} | |
ps.execute(); | |
} | |
}); | |
throw new RuntimeException(); | |
} | |
}); | |
} catch (Throwable e) { | |
e.printStackTrace(); | |
} | |
assertEquals(0, dao.count(Pet.class)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fixed?