package example.u2ware.springfield.part1.step2; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; 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.JPA ) @Entity public @ToString class JpaBean { @Id @GeneratedValue private @Getter @Setter Integer id; private @Getter @Setter String password; private @Getter @Setter String name; private @Getter @Setter String address; }
@Springfield(strategy=Strategy.JPA) 선언으로 다음 3개의 Bean 이 자동 생성, 등록 된다.
bean id | bean type | implements |
"jpaBeanController" | EntityController<JpaBean, JpaBean> | com.u2ware.springfield.controller. EntityHandler |
"jpaBeanService" | EntityService<JpaBean, JpaBean> | com.u2ware.springfield.service. EntityServiceImpl |
"jpaBeanRepository" | EntityRepository<JpaBean, Integer> | com.u2ware.springfield.repository.jpa. EntityJpaRepository |
orm.jpa.defaultPersistenceUnitName=em
orm.jpa.hibernate.dialect=org.hibernate.dialect.HSQLDialect
#orm.jpa.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
#orm.jpa.hibernate.hbm2ddl.auto=validate
orm.jpa.hibernate.hbm2ddl.auto=update
orm.jpa.hibernate.show_sql=true
orm.jpa.hibernate.format_sql=true
EntityController 는 CRUD 를 기본으로 한 9 개의 method 에 RequestMapping 한다.
매핑 경로 | HTTP Method | Controller Method 이름 | 예제 Command 객체 | 예제 매핑 경로 |
/{topLevelMapping}/ | GET | home | JpaBean | /part1/step2/ |
/{topLevelMapping} | GET | findForm | JpaBean | /part1/step2 |
/{topLevelMapping} | POST | find | JpaBean | /part1/step2 |
/{topLevelMapping}/{id} | GET | read | JpaBean | /part1/step2/7 |
/{topLevelMapping}/new | GET | createForm | JpaBean | /part1/step2/new |
/{topLevelMapping}/new | POST | create | JpaBean | /part1/step2/new |
/{topLevelMapping}/{id}/edit | GET | updateForm | JpaBean | /part1/step2/7/eidt |
/{topLevelMapping}/{id}/edit | PUT | update | JpaBean | /part1/step2/7/eidt |
/{topLevelMapping}/{id}/edit | DELETE | delete | JpaBean | /part1/step2/7/eidt |