jpa错误在关系属性中使用非实体[类ch.printsoft.mailhouse.usermgr.entity.Department]作为目标实体 [英] jpa error uses a non-entity [class ch.printsoft.mailhouse.usermgr.entity.Department] as target entity in the relationship attribute

查看:123
本文介绍了jpa错误在关系属性中使用非实体[类ch.printsoft.mailhouse.usermgr.entity.Department]作为目标实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将我的DepartmentMandator类持久保存到hsqhldb,但这会出现此错误.

I try to persist my Department and Mandator classes to hsqhldb but it gives this error.

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)

这些是我尝试保留到数据库的类.我真的不知道问题出在哪里.

These are the classes that I try to persist to my database. I really don't know what the problem is.

@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;

我真的尝试了所有事情,但是没有用.

I've really tried every thing but it didn't work.

推荐答案

确保在persistence.xml中列出了两个类,并且两个类都在类路径上.

Ensure you have both classes listed in your persistence.xml, and the both classes are on the classpath.

请包括您的persistence.xml.

Please include your persistence.xml.

这篇关于jpa错误在关系属性中使用非实体[类ch.printsoft.mailhouse.usermgr.entity.Department]作为目标实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆