package example.u2ware.springfield.part1.step1;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import com.u2ware.springfield.config.Springfield;
import com.u2ware.springfield.config.Springfield.Strategy;
@Springfield(
strategy=Strategy.SQLSESSION,
identity={"id"}
)
public @ToString class MybatisBean {
private @Getter @Setter Integer id;
private @Getter @Setter String password;
private @Getter @Setter String name;
private @Getter @Setter String address;
}
<mapper namespace="example.u2ware.springfield.part1.step1.MybatisBean">
<select id="exists"> .... </select>
<insert id="create"> .... </insert>
<select id="read"> .... </select>
<update id="update"> .... </update>
<delete id="delete"> .... </delete>
<select id="findAll"> .... </select>
<select id="findAllCount"> .... </select>
</mapper>
@Springfield(strategy=Strategy.SQLSESSION) 선언으로 다음 3개의 Bean 이 자동 생성, 등록 된다.
| bean name | bean type | bean implement |
| "mybatisBeanController" | EntityController<MybatisBean, MybatisBean> | com.u2ware.springfield.controller. EntityHandler |
| "mybatisBeanService" | EntityService<MybatisBean, MybatisBean> | com.u2ware.springfield.service. EntityServiceImpl |
| "mybatisBeanRepository" | EntityRepository<MybatisBean, Integer> | com.u2ware.springfield.repository.sqlsession. EntitySqlsessionRepository |
orm.sqlsession.configLocation=
orm.sqlsession.mapperLocationsPattern=/**/*.sqlsession.xml
EntityController 는 CRUD 를 기본으로 한 9 개의 method 에 RequestMapping 한다.
| 매핑 경로 | HTTP Method | Controller Method 이름 | 예제 Command 객체 | 예제 매핑 경로 |
| /{topLevelMapping}/ | GET | home | MybatisBean | /part1/step1/ |
| /{topLevelMapping} | GET | findForm | MybatisBean | /part1/step1 |
| /{topLevelMapping} | POST | find | MybatisBean | /part1/step1 |
| /{topLevelMapping}/{id} | GET | read | MybatisBean | /part1/step1/7 |
| /{topLevelMapping}/new | GET | createForm | MybatisBean | /part1/step1/new |
| /{topLevelMapping}/new | POST | create | MybatisBean | /part1/step1/new |
| /{topLevelMapping}/{id}/edit | GET | updateForm | MybatisBean | /part1/step1/7/eidt |
| /{topLevelMapping}/{id}/edit | PUT | update | MybatisBean | /part1/step1/7/eidt |
| /{topLevelMapping}/{id}/edit | DELETE | delete | MybatisBean | /part1/step1/7/eidt |