0
我在創建具有對象引用的JPA複合關鍵字時遇到了一些問題。實體是如顯示在波紋管,具有對象引用的JPA複合關鍵字
1)I灣,以除去從工作流實體的ID字段和製成一複合物鍵相結合SEQNO字段和模板(對象引用)字段
2 )根據更改更新現有的關係命令實體(@JoinColumn(name =「WORKFLOW_ID」,referencedColumnName =「ID」))
謝謝。
模板實體:
@Entity
@Table(name = "template")
public class Template implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name="template_se", sequenceName="TEMPLATE_SE", allocationSize=1, initialValue=1)
@Basic(optional = false)
@Column(name = "ID")
private Integer id;
@Basic(optional = false)
@Column(name = "NAME", unique = true)
private String name;
@OneToMany(cascade = CascadeType.REMOVE, mappedBy = "template")
@LazyCollection(LazyCollectionOption.FALSE)
private List<Workflow> workflowList;
}
工作流實體:
@Entity
@Table(name = "workflow")
public class Workflow implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name="wf_se", sequenceName="WF_SE", allocationSize=1, initialValue=1)
@Basic(optional = false)
@Column(name = "ID")
private Integer id;
@Basic(optional = false)
@Column(name = "SEQ_NO")
private int seqNo;
@JoinColumn(name = "T_ID", referencedColumnName = "ID", nullable = false)
@ManyToOne
private Template template;
@Basic(optional = false)
@Column(name = "NAME")
private String name;
}
命令實體:
@Entity
@Table(name = "command")
public class Command implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name="command_se", sequenceName="COMMAND_SE", allocationSize=1, initialValue=1)
@Basic(optional = false)
@Column(name = "ID")
private Integer id;
@JoinColumn(name = "WORKFLOW_ID", referencedColumnName = "ID")
@ManyToOne(optional = false)
private Workflow workflow;
}