Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JPA mapping of Self referenced class

Henrique Ordine
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have this self referenced class mapped with JPA annotations. When I declared the property that will contain the children elements of this object as a Set, it works fine. When I declare it as a Collection, I get the following error:

Exception Description: An incompatible mapping has been encountered between [class] and [class]. This usually occurs when the cardinality of a mapping does not correspond with the cardinality of its backpointer.
at oracle.toplink.essentials.exceptions.ValidationException.invalidMapping(
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataValidator.throwInvalidMappingEncountered(
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.OneToManyAccessor.process(
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.processRelationshipDescriptors(
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.process(
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(
at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(
... 77 more

And here`s how my class is writen:

Could anyone please help?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!