How to use enums with JPA

前端 未结 11 1096
梦如初夏
梦如初夏 2020-12-03 02:47

I have an existing database of a film rental system. Each film has a has a rating attribute. In SQL they used a constraint to limit the allowed values of this attribute.

11条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 03:05

    have you tried to store the ordinal value. Store the string value works fine if you don't have an associated String to the value:

    @Enumerated(EnumType.ORDINAL)
    

提交回复
热议问题