Can not set ManyToOne field to inherited entity [message #901019] |
Thu, 09 August 2012 08:26  |
Eclipse User |
|
|
|
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
|
|
|
|
|
Re: Can not set ManyToOne field to inherited entity [message #905034 is a reply to message #901769] |
Wed, 29 August 2012 11:23  |
Eclipse User |
|
|
|
Your issue seems to be class loader related.
JUnit does some odd class loader things depending on how you run it, you seem to be encounter this, but sharing your emf from previous tests.
You need to set JUnit to run the tests with the same class loader, or not share anything between them.
|
|
|
Powered by
FUDForum. Page generated in 0.03826 seconds