[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);
 }
 
}





+ Recent posts