[英]EclipseLink: Missing class for indicator field value of typ
My application runs on Payara and provides a REST API but when I try to create an object with a POST request I get the following exception: 我的应用程序在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)
...
On the contrary everything is fine and no errors occur when I am executing the program on Wildfly which uses Hibernate. 相反,当我在使用Hibernate的Wildfly上执行程序时,一切都很好并且没有错误发生。
Entities: 实体:
@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: REST API:
@POST
public Response create(Throw entity) {
em.persist(entity);
return Response.created(URI.create("...")).build();
}
I think that Eclipselink has problems to unmarshal my json. 我认为Eclipselink解决我的json问题。 Do I need any additional annotation?
我还需要任何其他注释吗?
如果使用名为“type”的字段,则会出现此错误。
Joined inheritance will by default use a 'type' field to determine the entity class to use, as does json/xml marshalling. 默认情况下,加入的继承将使用'type'字段来确定要使用的实体类,json / xml编组也是如此。 You have a type field, but populated it with "Miss' which can't be converted to a class.
您有一个类型字段,但填充了“Miss”,无法将其转换为类。
See 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 if you can change the JSON being posted. 请参阅eclipselink / Moxy:继承和属性名称开发,基于自定义策略的类型或https://www.eclipse.org/eclipselink/documentation/2.4/moxy/type_level003.htm,如果您可以更改发布的JSON。
The type field within JPA is somewhat discussed here http://www.coderanch.com/t/489497/ORM/databases/InheritanceType-JOINED-DiscriminatorColumn and here https://en.wikibooks.org/wiki/Java_Persistence/Inheritance#No_class_discriminator_column_2 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.