내 앱 시작시 최대 절전 모드에서 새로운 제약 조건을 추가하여 테이블을 변경하고 있습니다. 다음은 내 문제의 전체 그림을 얻는 샘플 코드입니다.JPA 데이터베이스의 기존 제약 조건을 인식하지 못합니다.
PostgreSQL의 스키마
create table public."A" {
a_id serial primary key
}
create table public."B" {
b_id serial primary key
}
create table public."C"(
a_id integer not null references public."A" (a_id),
b_id integer not null references public."B" (b_id),
)
DB 모델 내 응용 프로그램 시작시
class A{
@Id
@Column(name = "a_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE)
public Integer aId;
}
class B {
@Id
@Column(name = "b_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE)
public Integer bId;
}
class C {
@ManyToOne
@JoinColumn(name = "a_id")
public A a;
@ManyToOne
@JoinColumn(name = "b_id")
public B b;
}
, 그것은 다시 제약 조건을 만드는 것입니다. DB에서
Hibernate: alter table public."C" add constraint FKk4caeiw8tynv7g0p13h5inaht foreign key (a_id) references public."A"
Hibernate: alter table public."C" add constraint FK4bsokehyo37wygp12onlu8fbl foreign key (b_id) references public."B"
는 내가 2 개 개의 새로운 제약
여기 잘못 될 수 무엇CONSTRAINT FKk4caeiw8tynv7g0p13h5inaht foreign key (a_id)
REFERENCES public."A" (a_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT FK4bsokehyo37wygp12onlu8fbl foreign key (b_id)
REFERENCES public."B" (b_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
참조 제약이 외에도 이미
CONSTRAINT "C_a_id_fkey" FOREIGN KEY (a_id)
REFERENCES public."A" (a_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "C_b_id_fkey" FOREIGN KEY (b_id)
REFERENCES public."B" (b_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
의 availble 것을 볼?
'persistence.xml'에서 정의한 스키마 생성 전략 ('hibernate.hbm2ddl.auto/avax.persistence.schema-generation.database.action')은 무엇입니까? – crizzis