我想這樣的關聯映射一個一對多到是地圖@Inheritance(strategy=InheritanceType.JOINED)
實體,但我有一個驗證異常時,我的加載應用程序:JPA繼承和兒童雙向一對多關係
內部異常:異常[的EclipseLink-7250](Eclipse持久 服務2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException異常
描述:[類model.item.weapon.WeaponStat ]使用非實體 [class item.weapon.Weapon]作爲目標實體關係 屬性[場上武器]。
這裏的基類:
@Entity
@Table(name = "ITEMS")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "SYSTYPE", discriminatorType = DiscriminatorType.INTEGER)
@DiscriminatorValue(value = "0")
public class Item implements Serializable {...
從Item
繼承的類Weapon
:
@Entity
@Table(name = "WEAPONS")
@PrimaryKeyJoinColumn(name = "ITEM_ID")
@DiscriminatorValue(value = "3")
public class Weapon extends Item {...
Weapon
包含OneToMany
屬性:
@OneToMany(mappedBy = "weapon")
private List<WeaponStat> stats;
而WeaponStat
:
@Entity
@Table(name = "WEAPON_STATS")
public class WeaponStat implements Serializable {...
[...code...]
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "WEAPON_ID")
private Weapon weapon;
[...code...]
有人有想法?
Is Weapon是否正確列出了persistence.xml文件中的所有其他實體?它是否註明了正確的javax.persistence.Entity註釋? –
我實際上在我的persistence.xml中使用了 false exclude-unlisted-classes>。如果我用' ... '手動指定所有實體'問題是一樣的。 是的進口是正確的。 –
user5343250
你不能做它 私人武器武器; =>私人物品武器;我知道它並不總是實際可行,但武器上的成員不同於違反LSP的物品https://en.wikipedia.org/wiki/Liskov_substitution_principle –