-1
최대 절전 모드 4.3.8을 사용 중입니다. 자바 스프링 웹 앱과 postgres db.기존 레코드에 외래 키가있는 최대 절전 모드 엔티티 생성
나는 B와 C
을 기록하는 두 개의 외래 키와 기록 A를이 기록 B가 이미 시스템에 존재. 레코드 C는 새 레코드이며 레코드 A를 저장할 때 추가됩니다. 레코드 A 레이아웃입니다.
A.primaryKey
A.foreignKey to B.primaryKey (already exists in system)
A.foreignKey to C.primaryKey (new record)
A.feildX
레코드 A를 어떻게 저장합니까? 당신의 도움이 여기에
에 대한
덕분에 classes.I이 오류를 설명하는 최대 절전 모드에 새로운 오전 엔티티입니다.
@Entity
@Table(name="atable")
public class Aclass {
@Id
@Column(name="arec_id")
private String id;
//Do not create a reference to the bclass in this object. however do write the bclass object with a foreign key reference back to this aclass object
? @Transient
? @OneToOne(cascade=?)
? @JoinTable(name="btable",[email protected](name="brec_id"))
? private Bclass bclass;
//Create a reference to the cclass object in this record and write the cclass object as well
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="crec_foreign_key",referencedColumnName="crec_id")
private Cclass cclass;
@Column(name="description")
private String description;
private VoiceEngineModel voiceEngineModel;
}
@Entity
@Table(name="btable")
public class Bclass {
@Id
@Column(name="brec_id")
private String id;
@Column(name="aref")
private String aref;
@Column(name="description")
private String description;
}
@Entity
@Table(name="ctable")
public class Cclass {
@Id
@Column(name="crec_id")
private String id;
@Column(name="description")
private String description;
}
후 귀하의 엔티티 클래스뿐만 아니라 지속성 코드의 소스 코드, 당신은 아직이있는 경우 –