EclipseLink:缺少 class 的 typ 指标字段值
EclipseLink: Missing class for indicator field value of typ
我的应用程序在 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)
...
相反,当我在使用 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
}
休息 API:
@POST
public Response create(Throw entity) {
em.persist(entity);
return Response.created(URI.create("...")).build();
}
我认为 Eclipselink 在解组我的 json 时有问题。我需要任何额外的注释吗?
联合继承默认使用 'type' 字段来确定要使用的实体 class,json/xml 编组也是如此。您有一个类型字段,但用无法转换为 class.
的“Miss”填充它
如果您可以更改正在发布的 JSON,请参阅 eclipselink/Moxy : inheritance and attribute name oveloading based on type for custom strategies or https://www.eclipse.org/eclipselink/documentation/2.4/moxy/type_level003.htm。
这里稍微讨论了 JPA 中的类型字段 http://www.coderanch.com/t/489497/ORM/databases/InheritanceType-JOINED-DiscriminatorColumn
和这里
https://en.wikibooks.org/wiki/Java_Persistence/Inheritance#No_class_discriminator_column_2
如果您使用名为 "type" 的字段,您将收到此错误。
我的应用程序在 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)
...
相反,当我在使用 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
}
休息 API:
@POST
public Response create(Throw entity) {
em.persist(entity);
return Response.created(URI.create("...")).build();
}
我认为 Eclipselink 在解组我的 json 时有问题。我需要任何额外的注释吗?
联合继承默认使用 'type' 字段来确定要使用的实体 class,json/xml 编组也是如此。您有一个类型字段,但用无法转换为 class.
的“Miss”填充它如果您可以更改正在发布的 JSON,请参阅 eclipselink/Moxy : inheritance and attribute name oveloading based on type for custom strategies or https://www.eclipse.org/eclipselink/documentation/2.4/moxy/type_level003.htm。
这里稍微讨论了 JPA 中的类型字段 http://www.coderanch.com/t/489497/ORM/databases/InheritanceType-JOINED-DiscriminatorColumn 和这里 https://en.wikibooks.org/wiki/Java_Persistence/Inheritance#No_class_discriminator_column_2
如果您使用名为 "type" 的字段,您将收到此错误。