Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Can not set ManyToOne field to inherited entity
Can not set ManyToOne field to inherited entity [message #901019] Thu, 09 August 2012 08:26 Go to previous message
Markus KARG is currently offline Markus KARG
Messages: 23
Registered: June 2011
Junior Member
Scenario:

P is marked as @Entity @Inheritance

C1 extends P and is marked as @Entity

C2 extends P and is marked as @Entity and has @ManyToOne referencing P (named "parent")

Using this we can build trees, as C2 has a tree uplink that can point to either C1 or C2 thanks to the common ancestor P:

C1
!
+- C2 ("parent" points to C1 instance)
...!
...+- C2 ("parent" points to C2 instance)
......!
......+- C2
.........!
............

Accessing a collection that contains C2 instances failes with the following message:

"Trying to set value [C1] for instance variable [parent] of type [P] in the object. The specified object is not an instance of the class or interface declaring the underlying field, or an unwrapping conversion has failed."

Well, as C1 is a descendent of P, the above message is wrong!

We are totally stuck now as we may not change the table schema, but have to deliver a JPA based software which is able to reflect this flexible type of trees. Is there a workaround or patch we can apply to convince EclipseLink that a C1 instance is definitively a P due to the inheritance?

(Already filed in bugzilla https://bugs.eclipse.org/bugs/show_bug.cgi?id=386389, but no comments so far)

Thanks!
Markus
 
Read Message
Read Message
Read Message
Read Message
Previous Topic:JPA-RS hooks and/or HATEOAS?
Next Topic:Anyone using EclipseLink-EIS
Goto Forum:
  


Current Time: Tue May 21 20:43:23 EDT 2013

Powered by FUDForum. Page generated in 0.12063 seconds