com.something.SuperClass에 ID 열 키 생성을 사용할 수 없습니다 :는 <노조 서브 클래스> (TABLE_PER_CLASS)
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class SuperClass implements Serializable {
private static final long serialVersionUID = -695503064509648117L;
long confirmationCode;
@Id
@GeneratedValue(strategy = GenerationType.AUTO) // Causes exception!!!
public long getConfirmationCode() {
return confirmationCode;
}
public void setConfirmationCode(long confirmationCode) {
this.confirmationCode = confirmationCode;
}
}
com.something.SubClass을 :
@Entity
public abstract class Subclass extends SuperClass {
private static final long serialVersionUID = 8623159397061057722L;
String name;
@Column(nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
을 제공합니다 이 예외 :
Caused by: org.hibernate.MappingException: Cannot use identity column key
generation with <union-subclass> mapping for: com.something.SuperClass
ID를 생성하는 가장 쉽고 편리한 방법은 무엇입니까? 저는 상속 전략을 변경하고 싶지 않습니다.
완벽한 솔루션. 에도 최대 절전 모드 포럼은이 솔루션을 갖고있는 것 같다 didnot, 그들은 주제 https://forum.hibernate.org/viewtopic.php?p=2319244&sid=4493aa54d27d3f81a0e27ecbdda075ae –
주위에 가고 있었다이 문제는 MySQL의 전용 또는 정기 함께가요 내가 테이블 당 접근법에 대한 비디오 중 하나를 보았을 때 포스트 그레스가 사용되었다는 점에서 잘 작동했다. – Prashant
최근에 Dropwizard 애플리케이션을 테스트 할 때이 문제가 발생했다. 필자의 경우에는 DW가 세션 팩토리를 생성 할 때 사용한 것과 동일한 구성 옵션을 사용하여 문제를 해결했습니다. 나는 정말로 "hibernate.id.new_generator_mappings"프로퍼티를 true로 설정하는 것이 무엇인지를 확신한다. 이것은 DW 0.7.0, Hibernate 4.3.1, DB는 H2입니다. – sfitts