springboot JPA Annotation @enumerated
1. Use
@Enumerated used to annotate enumerated fields, corresponding to the enum type of MySQL
The source code supports 2 types of public
enum Enumtype {
ORDINAL,//According to the enumerated subscript
STRING; By the name of the enumeration,
private Enumtype () {
}
}
Import Lombok.
Allargsconstructor; Import Lombok.
Data; Import Lombok.
Noargsconstructor;
Import lombok.experimental.Accessors;
Import lombok.extern.slf4j.Slf4j;
Import Org.hibernate.annotations.DynamicInsert;
Import Org.hibernate.annotations.DynamicUpdate;
Import Org.springframework.http.HttpMethod;
Import javax.persistence.*;
Import java.io.Serializable;
Import Java.util.Date; /** * @author Created by Tan Jian on 2018/4/20 0020. Friday.
8:56. *©all Rights Reserved. /@Data @NoArgsConstructor @AllArgsConstructor @Accessors (chain = True) @Slf4j @Entity (name = visit_info) @Table Micinsert @DynamicUpdate public class VisitInfo implements serializable{private static final long Serialversionuid
= 6906097418517275871L;
@Id @GeneratedValue (strategy = generationtype.identity) Private Long pkid;
Private Date gmtmodify;
Private Date gmtcreate;
Private String IP;
Private String location;
Private Long userId;
@Enumerated (enumtype.string)Private HttpMethod method; }