|Can not set ManyToOne field to inherited entity [message #901019]
||Thu, 09 August 2012 08:26
| Markus KARG
Registered: June 2011
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:
+- C2 ("parent" points to C1 instance)
...+- C2 ("parent" points to C2 instance)
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)
Powered by FUDForum
. Page generated in 0.03194 seconds