Short introduction to the http methods in the spring context.
ProcessConfigControllerWorkshop
, ProcessConfigServiceWorkshop
ProcessConfigController
, ProcessConfigService
HTTP method | Request has body | Response has body |
---|---|---|
POST | V | V |
PUT | V | V |
PATCH | V | V |
GET | O | V |
OPTIONS | O | V |
DELETE | O | V |
CONNECT | O | V |
TRACE | X | V |
HEAD | O | X |
HTTP method | Safe | Idempotent | Cacheable |
---|---|---|---|
GET | V | V | V |
HEAD | V | V | V |
OPTIONS | V | V | X |
TRACE | V | V | X |
PUT | X | V | X |
DELETE | X | V | X |
POST | X | X | V |
CONNECT | X | X | X |
PATCH | X | X | X |
@GetMapping
@RequestMapping(method = RequestMethod.X)
@RequestMapping
methods mapped to “GET” are also implicitly mapped to “HEAD”, i.e. there is no need to have “HEAD”suppose we have tables
PROCESS_CONFIG_PROPERTIES (actually a map of properties for each process config)
|PROCESS_CONFIG_ID |VALUE |KEY |
|—- |—- |—- |
|1 |value1 |key1 |
|1 |value2 |key2 |
PROCESS_CONFIG
|ID |
|—- |
|1 |
@ElementCollection
@CollectionTable(name = "process_config_properties",
joinColumns = {@JoinColumn(name = "process_config_id", referencedColumnName = "id")})
@MapKeyColumn(name = "key")
@Column(name = "value")
private Map<String, String> properties = new HashMap<>();
@ElementCollection
- mainly for mapping non-entities (basic type or embeddable class)@OneToMany
- is only for mapping entities@ElementCollection
annotations could be omitted, but defaults are not always handy@CollectionTable
- specifies the table that is used for the mapping of collections of basic or embeddable types@MapKeyColumn
- mapping for the key column@Column
- mapping for the value column