我们正在尝试与 EclipseLink/MongoDB 建立 @OneToMany 和 @ManyToOne 关系:
@OneToMany 声明如下所示:
@Entity
@NoSql(dataType = "ServiceCatalog", dataFormat = DataFormatType.MAPPED)
public class ServiceCatalog {
@Id
@GeneratedValue
@Field(name = "_id")
private String id;
@OneToMany
private List<ServiceCatalogNeedCategory> serviceCatalogNeedCategories;
…
另一方面,@ManyToOne 声明:
@Entity
@NoSql(dataType = "NeedCategory", dataFormat = DataFormatType.MAPPED)
public class ServiceCatalogNeedCategory {
@Id
@GeneratedValue
@Field(name = "_id")
private String id;
@Field(name = "title")
private String Title;
@ManyToOne(fetch=FetchType.LAZY)
private ServiceCatalog serviceCatalog;
...
上述配置导致如下错误:org.eclipse.persistence.eis.mappings.EISOneToOneMapping cannot be cast to org.eclipse.persistence.mappings.OneToOneMapping
我们确实需要能够解决两个方向。
干杯迈克尔