[applicationContext.xml]
<!-- ibatis -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:sql/SqlMapConfig.xml</value>
</property>
<property name="dataSource" ref="dataSource"></property>
</bean>
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
[HelloDaoImpl.java]
import java.sql.SQLException;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;
import com.tistory.devdiaries.dto.Test;
@Repository("helloDaoImpl")
public class HelloDaoImpl implements HelloDao {
@Autowired
SqlMapClientTemplate sqlMapClientTemplate;
public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) {
this.sqlMapClientTemplate = sqlMapClientTemplate;
}
Test test;
@Override
public List<Test> getTestList() throws SQLException {
return (List<Test>)sqlMapClientTemplate.queryForList("HelloSql.getTestList", test);
}
}
'Database > MyBatis' 카테고리의 다른 글
[delete] 개인정보 모든테이블 삭제 (0) | 2016.01.12 |
---|---|
[Procedure] ibatis 호출 (0) | 2015.02.12 |
org.springframework.dao.DataAccessResourceFailureException / RecoverableDataAccessException (0) | 2014.03.25 |
[iBatis] Multi Insert 시 List 형태와 Map 형태 (0) | 2014.02.24 |
[iBatis] resultMap 할 시 값이 return 되지 않는 현상 (0) | 2013.02.25 |