해당 RecordNotification에 포인트를 기록하는 속성을 추가해야합니다. 그런 다음 계단식 삭제로 표시 할 수 있습니다. 이처럼 :
@Entity
public class Record {
@Id
private int id;
@OneToOne(mappedBy="record", cascade={CascadeType.REMOVE})
private RecordNotification notification;
public Record(int id) {
this.id = id;
}
protected Record() {}
}
@Entity
public class RecordNotification {
@Id
private int id;
@OneToOne
private Record record;
public RecordNotification(int id, Record record) {
this.id = id;
this.record = record;
}
protected RecordNotification() {}
}
생성 된 DDL했다 :, 커밋 다음 Record
을 삭제하고 RecordNotification
멀리가는 것을주의하는 Record
과 RecordNotification
을 만드는 :이 작동하는지 확인했습니다
create table Record (
id integer not null,
primary key (id)
);
create table RecordNotification (
id integer not null,
record_id integer,
primary key (id)
);
alter table RecordNotification
add constraint FKE88313FC6EE389C1
foreign key (record_id)
references Record;
.
나는 Hibernate 4.1.4.Final을 사용했다. 이것이 당신을 위해 작동하지 않는다면, 나는 EclipseLink에서 버그 또는 오작동을 의심합니다.
나는 그것이 나에게 오류를 주려고했다 : (기록은 클래스 A, recordNotification 클래스 B) – eclipse
글쎄 그건 부끄러운 일이다. –
예외 : [EclipseLink-4002] (Eclipse Persistence Services - 2.1.2.v20101206-r8635) : org.eclipse.persistence.exceptions.DatabaseException 내부 예외 : java.sql.SQLException : 무결성 제약 조건 위반 FK_RECORDNOTIFICATION_RECORD_ID -8 전화 : T_RECORD에서 삭제하는 WHERE (? ID =) 이 \t 바인드 => [qTBN-UatHhlnlX이-XHFrrvzKOPQJ4iCfMCWy__3LxcyM] – eclipse