我有两个模型:
@Entity
@Table(name="table_entry")
public class TableEntry extends Model {
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="clone_id", referencedColumnName="clone_id")
public GeneData gene_data;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@Constraints.Required
public String strain;
public String clone_id;
public String exp_type;
...
和
@Entity
@Table(name="gene_data")
public class GeneData extends Model {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@ManyToOne
public List<TableEntry> entry;
public String clone_id;
public String gene_name;
public String wb_id;
...
我想table_entry
加入clone_id
。但是,并非每一行 intable_entry
都有一行gene_data
。所以我想gene_data
在加入期间找不到它时为空。这可能吗?
我究竟做错了什么?我不断收到此错误
We got the following error:
Referential integrity constraint violation:
"FK_TABLE_ENTRY_GENE_DATA_1:
PUBLIC.TABLE_ENTRY FOREIGN KEY(CLONE_ID) REFERENCES
PUBLIC.GENE_DATA(CLONE_ID) ('Y56A3A.19')";