我試圖將我的Department
和Mandator
類保留到hsqhldb,但它會產生此錯誤。jpa錯誤使用非實體[class ch.printsoft.mailhouse.usermgr.entity.Department]作爲關係屬性中的目標實體
Exception Description: [class ch.printsoft.mailhouse.usermgr.entity.Mandator] uses a non-entity [class ch.printsoft.mailhouse.usermgr.entity.Department] as target entity in the relationship attribute [field departments].
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:115)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
這些是我嘗試堅持我的數據庫的類。我真的不知道問題是什麼。
@Entity
public class Mandator {
@Id
@GeneratedValue
private Integer id;
private String mandatorId;
@OneToMany(mappedBy = "mandator")
private List<MandatorUser> mandatorUsers;
@OneToMany(mappedBy = "mandator")
private List<SLAFamilyGroup> slaFamilyGroups;
@OneToMany(mappedBy = "mandator")
private List<Group> groups;
@OneToMany(mappedBy = "mandator")
private List<Department> departments;
@OneToMany(mappedBy = "mandator")
private List<CostUnit> costUnits;
@Entity
public class Department {
@Id
@GeneratedValue
private Integer id;
private String name;
private String responsiblePerson;
private String location;
@ManyToOne(optional = false)
private Mandator mandator;
@ManyToMany
private List<DocumentUser> documentUsers;
我真的嘗試過所有的東西,但沒有奏效。
ok ..會嘗試它非常多 –
異常說明:[class ch.printsoft.mailhouse.usermgr.entity.Mandator]使用非實體[class ch.printsoft.mailhouse.usermgr.entity.Department] as關係屬性中的目標實體[字段部門]。 –
從Department部門刪除@ManyToOne批註上的@ManyToOne批註中的「optional = false」 – WeMakeSoftware