001package com.avaje.ebean; 002 003/** 004 * Execute a TxCallable in a Transaction scope. 005 * <p> 006 * Use this with the {@link Ebean#execute(TxCallable)} method. 007 * </p> 008 * <p> 009 * Note that this is basically the same as TxRunnable except that it returns an 010 * Object (and you specify the return type via generics). 011 * </p> 012 * <p> 013 * See also {@link TxRunnable}. 014 * </p> 015 * 016 * <pre class="code"> 017 * Ebean.execute(new TxCallable<String>() { 018 * public String call() { 019 * User u1 = Ebean.find(User.class, 1); 020 * User u2 = Ebean.find(User.class, 2); 021 * 022 * u1.setName("u1 mod"); 023 * u2.setName("u2 mod"); 024 * 025 * Ebean.save(u1); 026 * Ebean.save(u2); 027 * 028 * return u1.getEmail(); 029 * } 030 * }); 031 * </pre> 032 * 033 * @see TxRunnable 034 */ 035public interface TxCallable<T> { 036 037 /** 038 * Execute the method within a transaction scope returning the result. 039 * <p> 040 * If you do not want to return a result you should look to use TxRunnable 041 * instead. 042 * </p> 043 */ 044 T call(); 045}