Hibernate로 매핑 된 클래스가 있는데 ManyToOne 주석이 때때로 데이터베이스에서 외래 키 제약을 유발하지만 (Oracle과 H2를 모두 시도했습니다) 때로는 그렇지 않습니다.
예를 들어, 여기에서는 source_id에 대한 제약 조건이 생성되지 않습니다.
@Entity
@Table( name = "onto_entry" )
@Inheritance ( strategy = InheritanceType.SINGLE_TABLE )
@DiscriminatorColumn ( name = "term_category" )
@DiscriminatorValue ( "generic" )
@SequenceGenerator( name = "hibernate_seq", sequenceName = "onto_entry_seq" )
public class OntologyEntry extends Identifiable
{
...
@ManyToOne ( targetEntity = ReferenceSource.class, cascade = {
CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH } )
@JoinColumn( name = "source_id" )
public ReferenceSource getSource ()
...
}
여기서 protocol_id에 대해 생성 된 FK 제약 조건을 얻습니다.
@Entity
@Table ( name = "protocol_application" )
public class ProtocolApplication extends Identifiable
{
@ManyToOne ( cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}, targetEntity = Protocol.class )
@JoinColumn ( name = "protocol_id" )
public Protocol getProtocol ()
...
}
내가 뭔가 잘못하고 있니? 그러한 행동에 영향을 미칠 수있는 요소는 무엇입니까?
나 자신에게 대답하러 간다.
Hibernate는 create 모드가 아닌 한 Oracle에서 조인 테이블 인덱스를 생성하지 않습니다 . 그래서 저는 JPA 주석을보고 부분적으로 자동화하여 직접하기로 결정했습니다. 이것이 내가 지금까지 한 일입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다