今天在將ejb3的工程部署到jboss啟動時報錯:
State: FAILED
Reason: javax.persistence.PersistenceException: org.hibernate.MappingException: Cannot use identity column key generation with <union-subclass> mapping for: com.xxx.xxxx
后來發(fā)現問題所在:
繼承策略我選擇了@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS),
同時在父類中設置了ID生成策略為:
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Long getId() {
return id;
}
而在這種策略下使用unnion-subclass 元素時 父類的標識屬性生成器不能使用“indentity” ,將策略改為
@GeneratedValue(strategy=GenerationType.TABLE)
問題解決。