Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » one-to-many not working with interface
one-to-many not working with interface [message #1108087] Fri, 13 September 2013 10:15 Go to next message
Hannes Kühtreiber is currently offline Hannes KühtreiberFriend
Messages: 21
Registered: June 2013
Junior Member
In our application we work with interfaces (Literature, Contact) and implementations (LiteratureImpl and ContactImpl).
The impls are mapped in xml-files, and querying and creating works fine.

There is a many-to-one relationship (a contact can donate n literature) which also works fine:
here is the snippet from the LiteratureImpl mapping file:

     <many-to-one name="originContact" 
          target-entity="lumo.core.biooffice.impl.ContactImpl">
          <join-column name="refOriginIdContact"/>
        </many-to-one>

now I try to make the relationship bi-directional and add the
inverse relation to the ContactImpl mapping file:

      <one-to-many name="donatedLiterature"
      	mapped-by="originContact" 	
      	target-entitiy="lumo.core.biooffice.impl.LiteratureImpl">
      </one-to-many>

I get the following error message:
[class lumo.core.biooffice.impl.ContactImpl] uses a non-entity
[class lumo.core.biooffice.Literature] as target entity in the relationship attribute
[method getDonatedLiterature]


so where does the interface (Literature) come from? in the inverse relation it works fine with the Impl!

Can anybody clarify what is going wrong here, and how can I fix this??
Hannes

Re: one-to-many not working with interface [message #1108367 is a reply to message #1108087] Fri, 13 September 2013 19:06 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
The <target-entitiy> is misspelled and likely causing it to be ignored, forcing the entity type to be picked up from the getDonatedLiterature method within ContactImpl. Fixing the tag should correct the issue.

Best Regards,
Chris
Re: one-to-many not working with interface [message #1109923 is a reply to message #1108367] Mon, 16 September 2013 05:59 Go to previous message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
you are right with this error.
after removing the typo, we gain a new exception (two different ones)

1) when using the *Impl in the mapping:

<one-to-many name="donatedLiterature"
            	   target-entity="lumo.core.biooffice.impl.LiteratureImpl" 
      			   mapped-by="originContact">


Exception [EclipseLink-127] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The get method for the attribute [donatedLiterature] does not return a ValueHolderInterface, but the mapping uses indirection.
Mapping: org.eclipse.persistence.mappings.OneToManyMapping[donatedLiterature]
Descriptor: RelationalDescriptor(lumo.core.biooffice.impl.ContactImpl --> [DatabaseTable(tContacts)])

Exception [EclipseLink-129] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The set method for the attribute [donatedLiterature] does not take a ValueHolderInterface as its parameter, but the mapping uses indirection.
Mapping: org.eclipse.persistence.mappings.OneToManyMapping[donatedLiterature]
Descriptor: RelationalDescriptor(lumo.core.biooffice.impl.ContactImpl --> [DatabaseTable(tContacts)])

if i understand this right, it moans about mapping an impl whereat the interface/impl only uses an interface.
there we go -> i change the mapping to the interface...

2) two ways?
a)
      <one-to-many name="donatedLiterature"
            	   target-entity="lumo.core.biooffice.Literature" 
      			   mapped-by="originContact">

Exception Description: [class lumo.core.biooffice.impl.LiteratureImpl] uses a non-entity [class lumo.core.biooffice.Contact] as target entity in the relationship attribute [method getOriginContact].

b)
      <one-to-many name="donatedLiterature"
            	   target-entity="Literature" 
      			   mapped-by="originContact">

Exception Description: [class lumo.core.biooffice.impl.LiteratureImpl] uses a non-entity [class Contact] as target entity in the relationship attribute [method getOriginContact].



i expected the last one wo be correct as the mapping is defined:
<entity class="lumo.core.biooffice.impl.ContactImpl" name="Contact">


any hints/solutions to this are welcome.
thanks in advance!

EDIT:
the definition of the getter/setter is this:
public Contact getOriginContact()

public void setOriginContact(Contact newOriginContact)

[Updated on: Mon, 16 September 2013 06:07]

Report message to a moderator

Previous Topic:Dynamic Moxy can not work together with JPA Lazy Loading
Next Topic:Using preInsert, preUpdate, prePersist, etc. to selectively prevent inserts and updates
Goto Forum:
  


Current Time: Fri Apr 19 21:47:22 GMT 2024

Powered by FUDForum. Page generated in 0.02989 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top