我有两个班加入,有很多关系。
我使用下面的代码来做到这一点
这是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<>();
}
这是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;
}
现在我需要为关联表添加更多其他属性。没有使用额外的实体类,有没有办法做到这一点。
我只需要解决使用此member.class和event_info.class
的方法如果没有办法,为什么会这样?
附加属性是日期