나는 일대일 관계를 가지고 있지만 스키마를 생성 할 때 hibernatetool이 불평한다.JPA Hibernate 일대일 관계
@Entity
public class Person {
@Id
public int id;
@OneToOne
public OtherInfo otherInfo;
rest of attributes ...
}
사람 OtherInfo와 일대일 관계를 가진다 : 다음은 문제점을 나타내는 예이다
@Entity
public class OtherInfo {
@Id
@OneToOne(mappedBy="otherInfo")
public Person person;
rest of attributes ...
}
사람 OtherInfo 측면을 소유한다. OtherInfo는 소유 측이므로 사람은 mappedBy
을 사용하여 Person의 속성 이름 "otherInfo"를 지정합니다. 왜
org.hibernate.MappingException: Could not determine type for: Person, at table: OtherInfo, for columns: [org.hibernate.mapping.Column(person)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
at org.hibernate.cfg.Configuration.iterateGenerators(Configuration.java:743)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:854)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:128)
...
어떤 생각 : 데이터베이스 스키마를 생성하는 hibernatetool를 사용하는 경우
나는 다음과 같은 오류가? 제가 잘못했거나 최대 절전 모드 버그입니까?
멋진 대답은, 당신이 당신의 Person 클래스에서뿐만 아니라 다음과 같은 주석을 추가해야 할 수도 추가 싶어 (I가 제대로 작동 것들을 얻을에 있었다) :'@Cascade ({CascadeType.ALL, CascadeType. DELETE_ORPHAN})' –
고마워, 내 문제에 도움이 .. 어쨌든 JPA 주석 만 사용하고 최대 절전 모드를 피할 수 있습니까? – Elton
@Elton - JPA 2.0에 있어야 할 방법이 있다면 - 나는 이것을 보지 않았다. – topchef