- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface IAtom
IAtom support transaction of database.
It can be invoked in Db.tx(IAtom atom) method.
Example:
Db.tx(new IAtom(){
public boolean run() throws SQLException {
int result1 = Db.update("update account set cash = cash - ? where id = ?", 100, 123);
int result2 = Db.update("update account set cash = cash + ? where id = ?", 100, 456);
return result1 == 1 && result2 == 1;
}});