I had two class join with many to many relationship.
I use below code to do that
this is Member.class
@Entity
@Data
@Table(name = "member")
public class Member implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToMany(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
@JoinTable(joinColumns = {
@JoinColumn(name = "member_id", referencedColumnName = "id", nullable = true) }, inverseJoinColumns = {
@JoinColumn(name = "event_info_id", referencedColumnName = "id", nullable = true) })
private Set<EventInfo> eventInfo= new HashSet<>();
}
This is Eventinfo.class
@Entity
@Table(name = "event_info")
@Data
public class EventInfo implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "event_name")
private String eventName;
@Column(name = "event_date")
@Temporal(TemporalType.DATE)
private Date eventDate;
@Column(name = "event_description")
private String eventDescription;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "eventInfo")
private Set<EventPic> eventPicSet;
@JoinColumn(name = "event_id", referencedColumnName = "id")
@ManyToOne(optional = false)
private Event event;
}
Now I need to add more additional attribute to associate table. Is there any way to do that without using additional entity class.
I need only way that solve using this member.class and event_info.class
if there is no way why is that?
additional attribute is date