我发现了很多这些问题,但由于某种原因,它们对我不起作用。所以,我显然做错了什么。
表单对象:
@Entity
@Table(name = "WEBFORMS_WEBFORM")
public class Form {
@Id
@GeneratedValue
@Column(name = "FORM_ID")
Long id;
@Column(name = "NAME")
String name;
@OrderBy("priority")
@OneToMany(mappedBy = "form", cascade={javax.persistence.CascadeType.ALL}, orphanRemoval = true)
Set<FormField> formFields;
@OrderBy("creationDate DESC")
@OneToMany(mappedBy = "form", cascade={javax.persistence.CascadeType.ALL}, orphanRemoval = true)
Set<FormResult> formResults;
@Column(name = "ALLOW_GUESTS")
Boolean allowGuest;
@Column(name = "SEND_MAIL")
Boolean sendMail;
表单域对象:
@Entity
@Table(name = "WEBFORMS_FORM_FIELD")
public class FormField {
@Id
@GeneratedValue
@Column(name = "FORM_FIELD_ID")
Long id;
@Column(name = "TYPE")
String type;
@Column(name = "CONTENT")
String content;
@Column(name = "PRIORITY")
Long priority;
@ManyToOne()
@JoinColumn(name = "FORM_ID")
public Form form;
我正在使用休眠注释:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
如果我在表单中创建一个表单字段对象,那么没有问题。两个对象都已创建。当我删除表单对象时,表单字段对象保留在数据库中。