我正在IntelliJ中使用JPA Buddy插件,我想从Student和Course(多对多关系)的实体类快速创建sql脚本(MySQL)。
我已经成功地创建了course和student表,但是JPA Buddy似乎没有创建关联(连接)表“student_course”的选项(如下图所示)?JPA Buddy是否可以创建多对多关系的关联(连接)表?
代码参考的学员和课程类:
Student.java
@Table(name = "student")
@Entity
@Getter
@Setter
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "name")
private String name;
@ManyToMany
@JoinTable(name = "student_course",
joinColumns = @JoinColumn(name = "student_id"),
inverseJoinColumns = @JoinColumn(name = "courses_id"))
private Set<Course> courses;
}
Course.java
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.util.Set;
@Table(name = "course")
@Entity
@Getter
@Setter
public class Course {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "name")
private String name;
@ManyToMany(mappedBy = "courses")
private Set<Student> students;
}
1条答案
按热度按时间gopyfrb31#
感谢您的举报!JPAB-1448 и JPAB-1469 ticket已关闭,自2022.1.0版JPA Buddy起运行