0

We're trying to do a @OneToMany and @ManyToOne relation with EclipseLink/MongoDB:

The @OneToMany declaration looks like this:

@Entity
@NoSql(dataType = "ServiceCatalog", dataFormat = DataFormatType.MAPPED)
public class ServiceCatalog {

@Id
@GeneratedValue
@Field(name = "_id")
private String id;

@OneToMany
private List<ServiceCatalogNeedCategory> serviceCatalogNeedCategories;
…

On the other side, the @ManyToOne declaration:

@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;
...

The above configuration leads to the following error: org.eclipse.persistence.eis.mappings.EISOneToOneMapping cannot be cast to org.eclipse.persistence.mappings.OneToOneMapping

We really need to be able to resolve both directions.

Cheers Michael

Michael Hunziker
  • 2,659
  • 3
  • 22
  • 26

2 Answers2

1

Please include the full exception stack.

There was an issue fixed in the 2.6 dev stream for NoSQL, it may be related.

https://twitter.com/j_b_sutherland/status/339727557928833025

What version are you using, I would try at least 2.5, or a recent 2.6 dev build.

James
  • 17,965
  • 11
  • 91
  • 146
0

You missed the MappedBy Annontation on the OneToMany side. See http://www.objectdb.com/api/java/jpa/OneToMany


[edit]

OMG it's NOSQL sorry.

ORM are no more what they used to be..

I don't know so, but if you're really using JPA API then it might be the trick

Gab
  • 7,869
  • 4
  • 37
  • 68
  • See http://stackoverflow.com/questions/2584521/in-a-bidirectional-jpa-onetomany-manytoone-association-what-is-meant-by-the-in for clarification. From DB perspective only the ServiceCatalogNeedCategory knows the catalog as it owns the fk. So you precise in the catalog where to identify associated categories – Gab Jun 17 '13 at 21:35