Hibernate @Enumerated mapping

后端 未结 4 2154
[愿得一人]
[愿得一人] 2020-12-05 04:39

Hibernate provides @Enumerated annotation which supports two types of Enum mapping either using ORDINAL or STRING. When w

4条回答
  •  我在风中等你
    2020-12-05 05:13

    public enum Status
    {
        OPEN("O"),
        WAITLIST("W"),
        COMPLETE("C")
    
    private String description;
    
    private Status(String description)
    {
       this.description = description;
    }
    
    public String getDescription()
    {
        return description;
    }
    }
    
    and then when you read it:
    
    Status.OPEN.getDescription()
    

提交回复
热议问题