I have an entity A and enum constant B. I did not define an entity for enum class. But there is a table defined for it. I have a join table that stores B enums belonging A entity.
In the entity A , I have to define this relationship. I want to read integer values for enum class. In normally we define this kind of relationship in following way.
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(name = "A_ENUMS", joinColumns = @JoinColumn(name = "A_ID", referencedColumnName = "ID", updatable = false),
inverseJoinColumns = @JoinColumn(name = "ENUM_ID", referencedColumnName = "ID", updatable = false))
private Collection<Integer> enums;
I tried this, but it did not work. Because I am loading integer, not entity. How can I do this via JPA?