• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPA mapping of Self referenced class  RSS feed

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

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 br.com.pedra.softbudget.domain.Category] and [class br.com.pedra.softbudget.domain.Category]. 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(ValidationException.java:1069)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataValidator.throwInvalidMappingEncountered(MetadataValidator.java:275)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.OneToManyAccessor.process(OneToManyAccessor.java:161)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:290)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.processRelationshipDescriptors(MetadataProject.java:579)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.process(MetadataProject.java:512)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:246)
at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:370)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:607)
... 77 more

And here`s how my class is writen:



Could anyone please help?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!