Skip to content

Instantly share code, notes, and snippets.

@electrum
Created June 6, 2012 03:19
Show Gist options
  • Save electrum/2879680 to your computer and use it in GitHub Desktop.
Save electrum/2879680 to your computer and use it in GitHub Desktop.
JDBI helpers
package jdbi.helpers;
import org.skife.jdbi.v2.Handle;
import org.skife.jdbi.v2.tweak.HandleCallback;
public abstract class VoidHandleCallback
implements HandleCallback<Void>
{
@Override
public final Void withHandle(Handle handle)
throws Exception
{
execute(handle);
return null;
}
protected abstract void execute(Handle handle)
throws Exception;
}
package jdbi.helpers;
import org.skife.jdbi.v2.Handle;
import org.skife.jdbi.v2.TransactionCallback;
import org.skife.jdbi.v2.TransactionStatus;
public abstract class VoidTransactionCallback
implements TransactionCallback<Void>
{
@Override
public final Void inTransaction(Handle handle, TransactionStatus status)
throws Exception
{
execute(handle, status);
return null;
}
protected abstract void execute(Handle handle, TransactionStatus status)
throws Exception;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment