In the following code I have a field shopType
which is actually a enum
, In my scenario one shop has multiple type for example shop ABC have type grocery as well as pharmacy , so I want to store a list of enum
in my database in separate table in which two column present one is shop_id
and other is shop_type
so that one shop can have multiple types How can i do this ?
here is my code
ShopDetail.java
@Entity
public class ShopDetail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String address;
private Double latitude;
private Double longitude;
private float rating;
private Time openingTime;
private Time closingTime;
@Enumerated(EnumType.STRING)
private Collection<ShopType> shopType;
@Column(columnDefinition=" bit(1)default 1")
private boolean shopEnabled = true;
//getters and setters
}
ShopType
public enum ShopType {
GROCERY,
PHARAMACY
}