I am working with Spring Boot JPA Hibernate. I have @ManyToMany relationship and Junction Table. One Entity is called Entity and the other Button. And then Junction Table is called ENTITY_BUTTONS
This Junction Table has some additional Columns. When I get a List of Button Children I would also like these additional columns to be included. But I am not sure how to do that.
So basically I don't want just a list of children but list of some other structure that will contains columns from the child and additional Columns from Junction Table for that Child relation.
My goal is to just be able to get top Entitiy and then that all the other entities and their children are automatically picked up in a complete hierarchy.
@javax.persistence.Entity
@Table(name = "ENTITIES")
public class Entity {
@ManyToMany(fetch = FetchType.LAZY)
@WhereJoinTable( clause = "active = true and is_deleted = false")
@JoinTable(
name = "ENTITY_BUTTONS",
joinColumns = @JoinColumn(name = "ENTITY_ID"),
inverseJoinColumns = @JoinColumn(name = "BUTTON_ID")
)
private List<Button> buttons;
}
@Entity
@Table(name = "BUTTONS")
public class Button { ... }