public static Atomic atomic(Runnable runnable) {
        try {
            AnimaQuery.beginTransaction();
            runnable.run();
            AnimaQuery.commit();
            return Atomic.ok();
        } catch (Exception e) {

            boolean isRollback = ifReturn(
                    of().rollbackException.isInstance(e),
                    () -> {
                        AnimaQuery.rollback();
                        return true;
                    },
                    () -> false);

            return Atomic.error(e).rollback(isRollback);
        } finally {
            AnimaQuery.endTransaction();
        }
    }
public static Atomic atomic ( Runnable runnable ) { try { AnimaQuery . beginTransaction ( ) ; runnable . run ( ) ; AnimaQuery . commit ( ) ; return Atomic . ok ( ) ; } catch ( Exception e ) { boolean isRollback = ifReturn ( of ( ) . rollbackException . isInstance ( e ) , ( ) -> { AnimaQuery . rollback ( ) ; return true ; } , ( ) -> false ) ; return Atomic . error ( e ) . rollback ( isRollback ) ; } finally { AnimaQuery . endTransaction ( ) ; } }
Code that performs a transaction operation.

@param runnable the code snippet to execute.
@return Atomic