// Path: myeslib-util/src/main/java/org/myeslib/util/jdbi/ClobToStringMapper.java
// public class ClobToStringMapper extends TypedMapper<String> {
// 	
// 	public ClobToStringMapper(){
// 		super();
// 	}
// 
// 	public ClobToStringMapper(int index)
//     {
//         super(index);
//     }
// 
// 	public ClobToStringMapper(String name)
//     {
//         super(name);
//     }
// 	
// 	@Override
// 	protected String extractByName(ResultSet r, String name) throws SQLException {
// 		Clob clob = r.getClob(name);
// 		try {
// 			return CharStreams.toString(clob.getCharacterStream());
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		} finally {
// 			clob.free();
// 		}
// 		return null;	
// 	}
// 
// 	@Override
// 	protected String extractByIndex(ResultSet r, int index) throws SQLException {
// 		Clob clob = r.getClob(index);
// 		try {
// 			return CharStreams.toString(clob.getCharacterStream());
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		} finally {
// 			clob.free();
// 		}
// 		return null;		
// 	}
// 
//     public static final ClobToStringMapper FIRST = new ClobToStringMapper();
// }


import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.sql.DataSource;
import lombok.extern.slf4j.Slf4j;
import org.myeslib.util.jdbi.ClobToStringMapper;
import org.skife.jdbi.v2.DBI;
import org.skife.jdbi.v2.Handle;
import org.skife.jdbi.v2.PreparedBatch;
import org.skife.jdbi.v2.TransactionCallback;
import org.skife.jdbi.v2.TransactionIsolationLevel;
import org.skife.jdbi.v2.TransactionStatus;
import org.skife.jdbi.v2.tweak.HandleCallback;
import com.hazelcast.core.QueueStore;
	public void delete(Long id) {
		deleteAll(Arrays.asList(id));
	}

	@Override
	public void deleteAll(final Collection<Long> ids) {
		log.info(String.format("deleting all within table %s", tableName));
		dbi.inTransaction(new TransactionCallback<Integer>() {
			@Override
			public Integer inTransaction(Handle h, TransactionStatus ts)
					throws Exception {
				PreparedBatch pb = h.prepareBatch(String.format("delete from %s where id = :id", tableName));
				for (Long id: ids){
					 pb.add().bind("id", id);
				}
				return pb.execute().length;
			}
		}) ;
	}

	@Override
	public String load(final Long id) {
		String result = null;
		try {
			log.info("will load {} from table {}", id.toString(), tableName);
			result = dbi.inTransaction(TransactionIsolationLevel.READ_COMMITTED,
					new TransactionCallback<String>() {
						@Override
						public String inTransaction(Handle h, TransactionStatus ts) throws Exception {
							String sql = String.format("select value from %s where id = :id", tableName);
// Path: myeslib-util/src/main/java/org/myeslib/util/jdbi/ClobToStringMapper.java
// public class ClobToStringMapper extends TypedMapper<String> {
// 	
// 	public ClobToStringMapper(){
// 		super();
// 	}
// 
// 	public ClobToStringMapper(int index)
//     {
//         super(index);
//     }
// 
// 	public ClobToStringMapper(String name)
//     {
//         super(name);
//     }
// 	
// 	@Override
// 	protected String extractByName(ResultSet r, String name) throws SQLException {
// 		Clob clob = r.getClob(name);
// 		try {
// 			return CharStreams.toString(clob.getCharacterStream());
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		} finally {
// 			clob.free();
// 		}
// 		return null;	
// 	}
// 
// 	@Override
// 	protected String extractByIndex(ResultSet r, int index) throws SQLException {
// 		Clob clob = r.getClob(index);
// 		try {
// 			return CharStreams.toString(clob.getCharacterStream());
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		} finally {
// 			clob.free();
// 		}
// 		return null;		
// 	}
// 
//     public static final ClobToStringMapper FIRST = new ClobToStringMapper();
// }


// Path: myeslib-util/src/main/java/org/myeslib/util/hazelcast/HzStringQueueStore.java
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.sql.DataSource;
import lombok.extern.slf4j.Slf4j;
import org.myeslib.util.jdbi.ClobToStringMapper;
import org.skife.jdbi.v2.DBI;
import org.skife.jdbi.v2.Handle;
import org.skife.jdbi.v2.PreparedBatch;
import org.skife.jdbi.v2.TransactionCallback;
import org.skife.jdbi.v2.TransactionIsolationLevel;
import org.skife.jdbi.v2.TransactionStatus;
import org.skife.jdbi.v2.tweak.HandleCallback;
import com.hazelcast.core.QueueStore;

	public void delete(Long id) {
		deleteAll(Arrays.asList(id));
	}

	@Override
	public void deleteAll(final Collection<Long> ids) {
		log.info(String.format("deleting all within table %s", tableName));
		dbi.inTransaction(new TransactionCallback<Integer>() {
			@Override
			public Integer inTransaction(Handle h, TransactionStatus ts)
					throws Exception {
				PreparedBatch pb = h.prepareBatch(String.format("delete from %s where id = :id", tableName));
				for (Long id: ids){
					 pb.add().bind("id", id);
				}
				return pb.execute().length;
			}
		}) ;
	}

	@Override
	public String load(final Long id) {
		String result = null;
		try {
			log.info("will load {} from table {}", id.toString(), tableName);
			result = dbi.inTransaction(TransactionIsolationLevel.READ_COMMITTED,
					new TransactionCallback<String>() {
						@Override
						public String inTransaction(Handle h, TransactionStatus ts) throws Exception {
							String sql = String.format("select value from %s where id = :id", tableName);
							return h.createQuery(sql).bind("id", id).map(ClobToStringMapper.FIRST).first();