Skip to content

Instantly share code, notes, and snippets.

@kinumi
Created September 8, 2012 12:21
Show Gist options
  • Save kinumi/3674361 to your computer and use it in GitHub Desktop.
Save kinumi/3674361 to your computer and use it in GitHub Desktop.
try-with-resourcesを使ったトランザクション/Finder
// Finder
try (Tx tx = new Tx(sf)) {
{
DBTest test = tx.from(DBTest.class).uniq();
assertNotNull(test);
}
{
DBTest test = tx.from(DBTest.class).where("name = 'aaa'").uniq();
assertNotNull(test);
}
{
List<DBTest> test = tx.from(DBTest.class).list();
assertEquals(1, test.size());
}
{
List<DBTest> test = tx.from(DBTest.class).where("name = 'aaa'").list();
assertEquals(1, test.size());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment