Created
August 27, 2012 08:56
-
-
Save benelog/3486770 to your computer and use it in GitHub Desktop.
iBatis snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.benelog.orm; | |
import java.util.List; | |
import org.springframework.orm.ibatis.SqlMapClientOperations; | |
/** | |
* @author benelog | |
* SqlMapClientOperations의 메소드를 generics를 이용해서 반복적인 캐스팅을 없애주는 역할을 함 | |
* | |
*/ | |
public class GenericRepositorySupport { | |
private SqlMapClientOperations client; | |
public GenericRepositorySupport(SqlMapClientOperations client) { | |
this.client = client; | |
} | |
@SuppressWarnings({ "unchecked" }) | |
protected <T> List<T> queryForList(String statementName) { | |
return client.queryForList(statementName); | |
} | |
@SuppressWarnings({ "unchecked" }) | |
protected <T> List<T> queryForList(String statementName, Object parameterObject) { | |
return client.queryForList(statementName, parameterObject); | |
} | |
@SuppressWarnings({ "unchecked" }) | |
protected <T> T queryForObject(String statementName) { | |
return (T) client.queryForObject(statementName); | |
} | |
@SuppressWarnings({ "unchecked" }) | |
protected <T> T queryForObject(String statementName, Object parameterObject) { | |
return (T) client.queryForObject(statementName, parameterObject); | |
} | |
protected int insert(String statementName, Object parameterObject){ | |
return client.update(statementName, parameterObject); | |
} | |
protected int delete(String statementName, Object parameterObject){ | |
return client.delete(statementName, parameterObject); | |
} | |
protected int update(String statementName, Object parameterObject){ | |
return client.update(statementName, parameterObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment