I am looking way to store EnumSet in mysql column with type set:
@Data
@Entity
@Table(name = "ENTITY_TABLE")
public class Entity implements Serializable {
@Id
@GeneratedValue
@Column(nullable = false)
@NotNull
private String id;
@Column(name = "types")
private EnumSet<Type> types;
}
Enum of type is defined as below:
public enum Type {
TYPE1,
TYPE2,
TYPE3,
TYPE4,
TYPE5
}
And table is defined below:
CREATE TABLE `ENTITY_TABLE` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`types` set('TYPE1','TYPE2','TYPE3','TYPE4','TYPE5') DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
And insert in table:
INSERT INTO ENTITY_TABLE (types) VALUE ( 'TYPE1','TYPE2')