这些是我的课程:
@Entity
@Table(name="assessment")
public class AssesmentProperties {
@Id
@Column(name="AssessmentId")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long AssessmentId;
@Column(unique=true,nullable=false)
private String AssessmentName;
private String AssessmentLevel;
private String Specialization;
private int time;
private String keywords;
private int NoOfSections;
//getters and setters
}
@Embeddable
public class SettingsPrimary implements Serializable {
private Long AssessmentId;
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long Section;
//getters and setters
}
@Entity
@Table(name="section")
public class SectionProperties {
@EmbeddedId
private SettingsPrimary PrimaryKey;
private String SectionType;
private int Weightage;
private int time;
private int NoOfQuestions;
//getters and setters
}
在table上 section
我需要创造 assessment_id
作为fk收件人 assessment
表并在删除时设置cascade。我试过用不同的方法做,但没有成功。
1条答案
按热度按时间svujldwt1#
也许这能帮你。
我把sectionproperties id改成了
Long
把评估属性Map成一个多对一的属性。这样,绑定到节的assessmentproperties总是会被删除,关联的节属性也会被删除。