Springboot JPA Annotation @enumerated

Source: Internet
Author: User
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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.