@Springfield - Search

Code

package com.u2ware.springfield.sample.part2.step1;

import lombok.Getter;
import lombok.Setter;

import com.u2ware.springfield.config.Springfield;
import com.u2ware.springfield.config.Springfield.Strategy;
import com.u2ware.springfield.repository.QueryMethod;

@Springfield(
	strategy=Strategy.JPA,
	entity=QueryEntity.class
)
@QueryMethod("findByIdAndPassword")
public class QueryBean {

	@Getter @Setter private String id;
	@Getter @Setter private String password;	
}
		
package com.u2ware.springfield.sample.part2.step1;

import javax.persistence.Entity;
import javax.persistence.Id;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Entity
public @ToString class QueryEntity {

	@Id
	@Getter @Setter private String id;
	@Getter @Setter private String password;
	@Getter @Setter private String name;
	@Getter @Setter private Integer age;
}
		

Beans

@Springfield(strategy=Strategy.JPA, entity=QueryEntity.class) 선언으로 다음 4개의 Bean 이 자동 생성, 등록 된다.

bean name bean type bean implement
"queryBeanController"EntityController<QueryEntity, QueryBean>com.u2ware.springfield.controller. EntityHandler
"queryBeanValidator" EntityValidator<QueryEntity, QueryBean> com.u2ware.springfield.validation. EntityValidatorImpl
"queryBeanService" EntityService<QueryEntity, QueryBean> com.u2ware.springfield.service. EntityServiceImpl
"queryEntityRepository"EntityRepository<QueryEntity, String>com.u2ware.springfield.repository.jpa. EntityJpaRepository
Note:
@Springfield 의 entity 속성으로 Entity Object를 지정할 수 있다.

RequestMapping

매핑 경로 HTTP Method Controller Method 이름 예제 Command 객체 예제 매핑 경로
/{topLevelMapping}/ GET home() QueryBean/part2/step1/
/{topLevelMapping} GET findForm() QueryBean/part2/step1
/{topLevelMapping} POST find() QueryBean/part2/step1
/{topLevelMapping}/{id} GET read() QueryEntity/part2/step1/foo
/{topLevelMapping}/new GET createForm()QueryEntity/part2/step1/new
/{topLevelMapping}/new POST create() QueryEntity/part2/step1/new
/{topLevelMapping}/{id}/editGET updateForm()QueryEntity/part2/step1/foo/eidt
/{topLevelMapping}/{id}/editPUT update() QueryEntity/part2/step1/foo/eidt
/{topLevelMapping}/{id}/editDELETEdelete() QueryEntity/part2/step1/foo/eidt

QueryMethod

예제에서 QueryBean class 의 @QueryMethod 선언값이 "findByIdAndPassword" 이므로, 이를 기본 Query Method 문자열로 한다.