使用JPA扩展程序扫描包含@Embedded对象的实体时,可以使用ComplexTypes正确创建$ metadata。但是,在检索实体时,我收到ClassCastException:
org.apache.olingo.odata2.core.edm.provider.EdmComplexTypeImplProv
无法转换为org.apache.olingo.odata2.api.edm.EdmSimpleType
类:
org.apache.olingo.odata2.jpa.processor.core.access.data.JPAEntityParse
这是我正在使用的实体代码:
@Entity
public class BORROWER {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Embedded
protected BORROWER_DETAIL borrower_DETAIL;
@Embedded
protected NAME name;
@ManyToOne
protected DEAL deal;
//Mark transient to force orika to skip
@Transient
public DEAL getDeal() {
return deal;
}
public void setDeal(DEAL deal) {
this.deal = deal;
}
/**
* Gets the value of the borrower_DETAIL property.
*
* @return
* possible object is
*
*
*/
public BORROWER_DETAIL getBORROWER_DETAIL() {
return borrower_DETAIL;
}
/**
* Sets the value of the borrower_DETAIL property.
*
* @param value
* allowed object is
*
*
*/
public void setBORROWER_DETAIL(BORROWER_DETAIL value) {
this.borrower_DETAIL = value;
}
public NAME getName() {
return name;
}
public void setName(NAME name) {
this.name = name;
}
public long getId() {
return id;
}
}
最佳答案
看到有关此getter / setter的评论是此bug票证上问题的根源(我也借用了部分问题写作):
https://issues.apache.org/jira/browse/OLINGO-948
我更新了border_DETAIL的getter和setter方法签名,而我不再遇到该错误。这是为我工作的更新的实体代码:
@Entity
public class BORROWER {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Embedded
protected BORROWER_DETAIL borrower_DETAIL;
@Embedded
protected NAME name;
@ManyToOne
protected DEAL deal;
//Mark transient to force orika to skip
@Transient
public DEAL getDeal() {
return deal;
}
public void setDeal(DEAL deal) {
this.deal = deal;
}
public BORROWER_DETAIL getBorrower_DETAIL() {
return borrower_DETAIL;
}
public void setBorrower_DETAIL(BORROWER_DETAIL borrower_DETAIL) {
this.borrower_DETAIL = borrower_DETAIL;
}
public NAME getName() {
return name;
}
public void setName(NAME name) {
this.name = name;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
关于java - Olingo 2.0.6 JPA扩展:无法将EdmComplexTypeImplProv强制转换为EdmSimpleType,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56708154/