Hibernate Eclipselink给出了验证异常

Hibernate Eclipselink给出了验证异常,hibernate,jpa,eclipselink,mysql-workbench,netbeans-8,Hibernate,Jpa,Eclipselink,Mysql Workbench,Netbeans 8,我使用MySQLWorkbench作为建模工具来创建数据库。我生成了一个简单的testDB,用于测试JPA/Eclipselink、Netbeans实体和web服务生成器。当我生成实体和服务时,我收到如下错误消息: Exception Description: [class com.rako.rma.Rma] uses a non-entity [class com.rako.rma.Product] as target entity in the relationship attribute

我使用MySQLWorkbench作为建模工具来创建数据库。我生成了一个简单的testDB,用于测试JPA/Eclipselink、Netbeans实体和web服务生成器。当我生成实体和服务时,我收到如下错误消息:

Exception Description: [class com.rako.rma.Rma] uses a non-entity [class com.rako.rma.Product] as target entity in the relationship attribute [field productserialNumberLOTN].
at org.eclipse.persistence.exceptions.ValidationException.nonEntityTargetInRelationship(ValidationException.java:1378)
军事革命实体

产品实体

问题:

1我的数据库设计有误吗

2 Netbeans JPA生成器是否正常工作


3如果它不能100%工作,我如何修正我的jpa符号,使这种关系工作

每个实体类都需要@Entity注释:

@Entity
public class Product implements Serializable {
...

当我粘贴到netbeans项目时,实体看起来很好。persistence.xml是什么样子的?服务器是否可以在之后启动,或者只是在生成问题时启动?当生成时,服务器不启动。Netbeans 8.02和Glassfish 4.1。我认为,作为pk的字符是问题所在。如果我添加一个字段serialNumberID作为主键,它只是自动递增int,那么一切都正常。问题是,即使服务器已启动并运行,Netbeans test REST中的REST服务也无法工作,但使用serialNumberID,REST服务可以工作……您所展示的内容似乎没有问题,所以问题可能是您的类路径上有多个类实例,这样就可以选择其他版本的产品。检查它是如何打包和部署的检查产品是否有任何lamdba表达式。这是有原因的。我有,但这不是我的理由。
public class Product implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 20)
@Column(name = "serialNumber_LOTN")
private String serialNumberLOTN;
@Size(max = 45)
@Column(name = "temp1")
private String temp1;
@Size(max = 45)
@Column(name = "temp2")
private String temp2;
@JoinColumn(name = "serialNumber_LOTN", referencedColumnName = "LOTN", insertable = false, updatable = false)
@OneToOne(optional = false)
private SerialNumber serialNumber;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "productserialNumberLOTN")
private Collection<Rma> rmaCollection;
public class SerialNumber implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 20)
@Column(name = "LOTN")
private String lotn;
@Size(max = 45)
@Column(name = "temp")
private String temp;
@OneToOne(cascade = CascadeType.ALL, mappedBy = "serialNumber")
private Product product;
@Entity
public class Product implements Serializable {
...