我在实体管理器启动期间解析实体时遇到问题。
现在它出现以下错误:
Exception [EclipseLink-197] (Eclipse Persistence Services -
2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException Exception
Description: The mapping [an_div] is not the appropriate type for this
descriptor Mapping:
org.eclipse.persistence.mappings.DirectToFieldMapping[an_div-->div]
Descriptor:
EISDescriptor(com.cloudyle.paasplus.api.fhir.model.dstu2.composite.NarrativeDt
--> [DatabaseTable(DATATYPE), DatabaseTable(NARRATIVEDT)])
抽象类配置:
@MappedSuperclass
@UuidGenerator(name = "UUID_GEN_SQL")
@NoSql(dataFormat = DataFormatType.MAPPED)
public abstract class AbstractBaseResource
{
private static final long serialVersionUID = -1212459053211153257L;
protected static final Logger logger = LoggerFactory.getLogger(AbstractBaseResource.class);
public static final String DELIMITER = ", ";
@Id
@GeneratedValue(generator = "UUID_GEN_SQL")
@Column(name = "_id")
private String id;
@Version
@Field(name = "object_version")
private Long objectVersion;
@Embedded
@Field(name = "text")
private NarrativeDt text;
// getter and setter
// ...
}
一个简单的实体类:
@Entity
@NoSql(dataFormat = DataFormatType.MAPPED)
public class Account extends AbstractBaseResource
{
@Field(name = "name")
private String an_name;
// other fields + getter and setter
// ...
}
问题所在的可嵌入实体:
@Embeddable
@NoSql(dataFormat = DataFormatType.MAPPED)
@Customizer(DtChildCustomizer.class)
public class NarrativeDt extends Datatype
{
@Field(name = "status")
private String an_status;
@Field(name = "div")
private String an_div;
// getter and setter
// ...
}
扩展的embbedable:
@Embeddable
@NoSql(dataFormat = DataFormatType.MAPPED)
@Customizer(DtParentCustomizer.class)
public abstract class Datatype implements IDatatype, Serializable
{
@Field(name = "element_specific_id")
private String an_elementSpecificId;
// getter and setter
// ...
}
儿童定制器:
public class DtChildCustomizer implements Serializable, DescriptorCustomizer
{
@Override
public void customize(final ClassDescriptor descriptor)
{
descriptor.getInheritancePolicy().setParentClass(Datatype.class);
}
}
父母定制器:
public class DtParentCustomizer implements Serializable, DescriptorCustomizer
{
@Override
public void customize(final ClassDescriptor descriptor) throws Exception
{
descriptor.getInheritancePolicy().setSingleTableStrategy();
final DatabaseField indicatorField = new DatabaseField();
indicatorField.setName("classType");
indicatorField.setLength(255);
indicatorField.setType(java.lang.String.class);
descriptor.getInheritancePolicy().setClassIndicatorField(indicatorField);
descriptor.getInheritancePolicy().useClassNameAsIndicator();
}
}
我无法理解为什么eclispeLink在解决简单映射方面存在问题an_div-> div。
所有建议都将受到赞赏,我已经花了太多时间来处理它。我看不到映射问题:(
亲切的问候