본문 바로가기

myBatis 3.2

[jUnit] Spring 3.2.3 + myBatis 3.2 Test suite 적용. 현재 작업하고 있는 프로젝트의 모든 프레임워크를 최신버전으로 세팅을 하고 서비스 클래스를 jUnit으로 작성해보았다... Maven jUnit dependency junit junit 4.7 test Maven Spring framework test org.springframework org.springframework.test 3.2.3.RELEASE AbstractApplicationContextTest.java package com.openerp.service.test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.contex..
myBatis DAO Pattern example GenericMyBatisDaoSupport.java package com.openerp.common.dao; import java.io.Serializable; import java.util.ArrayList; import org.apache.ibatis.exceptions.PersistenceException; public interface GenericMyBatisDaoSupport{ public T get(PK id) throws PersistenceException;//get obj of type T by the primary key 'id' public ArrayList getAll() throws PersistenceException;//get all objects of type T publ..
MyBatis 3.2) Mapper 방식과 DAO Pattern은 같이 사용할 수 없다. Mapper 방식은 아래 처럼 사용한다. pacakge com.openerp.dao public interface RoleDao{ List listRole(Parameters params); List listRole(Parameters params, int pg, int ps); } 이 경우 Mapper에 등록을 했기때문에 roleMapper 라는 이름으로 bean에 등록이 된다. "예전부터 사용해오던 DAO 패턴을 같이 쓸 수 없을까?" 라는 궁금증이 생겨 반나절동안 해 보았는데... 안된다. DAO 패턴도 어쨋든 Spring DI에 등록이 되어야 하는데 같은 클래스가 두개의 이름으로 등록이 되는 현상이 발생된다. No qualifying bean of type [com.openerp.dao.RoleD..
Spring 3.2.3 + myBatis 3.2.2 기존에 사용하던 Spring 3.1에서 3.2.3으로 변경했다. 하는김에 myBatis도 최신으로 변경.. 이러다가 그냥 back-end를 다 최신으로 변경하기로 작정하고 작업 진행.. applicationContext.xml 에서 myBatis 설정이 조금 변경되었다. org.springframework.orm.ibatis.support.SqlMapClientDaoSupport as of Spring 3.2, in favor of the native Spring support in the Mybatis follow-up project (http://code.google.com/p/mybatis/) org.springframework.orm.ibatis.SqlMapClientFactoryBean as o..