java - EclipseLink:类型的指示器字段值缺少类

标签 java rest jpa glassfish eclipselink

我的应用程序在 Payara 上运行并提供了 REST API,但是当我尝试使用 POST 请求创建对象时,出现以下异常:

Exception [EclipseLink-43] (Eclipse Persistence Services - 2.6.0.payara-p1): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Missing class for indicator field value [Miss] of type [class java.lang.String].
Descriptor: XMLDescriptor(at.htl.handballinheritance.entity.Throw --> [DatabaseTable(event), DatabaseTable(dataObject)])
  at org.eclipse.persistence.exceptions.DescriptorException.missingClassForIndicatorFieldValue(DescriptorException.java:940)
  at org.eclipse.persistence.internal.oxm.QNameInheritancePolicy.classFromRow(QNameInheritancePolicy.java:278)
  ...

Full Stacktrace

相反,当我在使用 Hibernate 的 Wildfly 上执行程序时,一切都很好,没有发生错误。

实体:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@XmlRootElement
public abstract class Event extends DataObject implements Serializable {
    ... 
}

@Entity
public class Throw extends Event implements Serializable {

    @Enumerated(EnumType.STRING)
    @NotNull
    private ThrowingType type;

    ...
}

public enum ThrowingType {
    Goal, Miss
}

REST API:

@POST
public Response create(Throw entity) {
    em.persist(entity);
    return Response.created(URI.create("...")).build();
}

我认为 Eclipselink 在解码我的 json 时有问题。我需要任何额外的注释吗?

最佳答案

如果您使用名为“type”的字段,您将收到此错误。

关于java - EclipseLink:类型的指示器字段值缺少类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33104232/

相关文章:

java - 过滤时很漂亮的 JSON 导入,但返回整批数据时则不然 + ID 中丑陋的括号

java - Fork Join 优化

java - 使用 Spring boot 的 SOAP 和 Rest Web 服务

java - 具有多个服务器的 JPA

java - JPA @EJB 注入(inject)不起作用并给出 NullPointerException

java - 使用 docx4j 查找节点元素的所属部分

Java : autoboxing of an Object array of integers, 从 LinkedList.toArray() 转换为 int

node.js - 我使用 express for node.js 得到冒号和我的参数

ajax - 使用 Rack::Test 测试 AJAX POST - 如何传递数据?

java - 生成复合 PK null id