Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
JPOX
Description
In the Employee-Insurance relationships, the same table is used for both relationships. The thing that distinguishes the relationships is the type of the instance. Employee has 0..1 instance of MedicalInsurance and 0..1 instance of DentalInsurance. Since these are both mapped to the same table, the query to retrieve the instance needs to qualify the SQL with the correct discriminator depending on the relationship being navigated.
The incorrect behavior results in a ClassCastException when run with application identity:
test(org.apache.jdo.tck.mapping.CompletenessTest)java.lang.ClassCastException: org.apache.jdo.tck.pc.company.DentalInsurance
at org.apache.jdo.tck.pc.company.Employee.jdoReplaceField(Employee.java)
at org.apache.jdo.tck.pc.company.FullTimeEmployee.jdoReplaceField(FullTimeEmployee.java)
at org.apache.jdo.tck.pc.company.Person.jdoReplaceFields(Person.java)
at org.jpox.state.StateManagerImpl.replaceFields(StateManagerImpl.java:2756)
at org.jpox.store.rdbms.request.FetchRequest.execute(FetchRequest.java:163)
at org.jpox.store.rdbms.table.ClassTable.fetch(ClassTable.java:1810)
at org.jpox.store.StoreManager.fetch(StoreManager.java:742)
at org.jpox.state.StateManagerImpl.loadNonDFGFields(StateManagerImpl.java:1612)
at org.jpox.state.StateManagerImpl.isLoaded(StateManagerImpl.java:1730)
at org.apache.jdo.tck.pc.company.Employee.jdoGetmedicalInsurance(Employee.java)
at org.apache.jdo.tck.pc.company.Employee.getMedicalInsurance(Employee.java:210)
at org.apache.jdo.tck.pc.company.Employee.deepCompareFields(Employee.java:447)
at org.apache.jdo.tck.pc.company.FullTimeEmployee.deepCompareFields(FullTimeEmployee.java:120)
at org.apache.jdo.tck.util.EqualityHelper.deepEquals(EqualityHelper.java:559)
at org.apache.jdo.tck.pc.company.Insurance.deepCompareFields(Insurance.java:144)
at org.apache.jdo.tck.pc.company.DentalInsurance.deepCompareFields(DentalInsurance.java:112)
at org.apache.jdo.tck.util.EqualityHelper.deepEquals(EqualityHelper.java:559)
at org.apache.jdo.tck.pc.company.Employee.deepCompareFields(Employee.java:447)
at org.apache.jdo.tck.pc.company.FullTimeEmployee.deepCompareFields(FullTimeEmployee.java:120)
at org.apache.jdo.tck.mapping.CompletenessTest.test(CompletenessTest.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:197)
at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:115)
at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:93)
It results in incorrect output when run with datastore identity:
test(org.apache.jdo.tck.mapping.CompletenessTest)junit.framework.AssertionFailedError: CompletenessTest failed; see list of failed instances below:
Expected this instance:
FullTimeEmployee(1, emp1Last, emp1First, born 9/Jun/1970, phone {}, hired 31/Dec/1998, weeklyhours 40.0, $20000.0)
Got persistent instance:
FullTimeEmployee(1, emp1Last, emp1First, born 9/Jun/1970, phone {}, hired 31/Dec/1998, weeklyhours 40.0, $20000.0)
Detailed list of differences follows...
Context: Employee<1>.dentalInsurance-> Insurance<11>.employee-> Employee<1>.medicalInsurance-> Insurance<1>.insid
expected '1'
actual '11'
Context: Employee<1>.dentalInsurance-> Insurance<11>.employee-> Employee<1>.medicalInsurance-> Insurance<1>.carrier
expected 'MedicalCarrier1'
actual 'DentalCarrier1'
Context: Employee<1>.dentalInsurance-> Insurance<11>.employee-> Employee<1>.medicalInsurance-> MedicalInsurance<1>.planType
Expected not null, actual null
expected 'PPO'
actual 'null'
Expected this instance:
MedicalInsurance(1, carrier MedicalCarrier1, planType PPO)
Got persistent instance:
MedicalInsurance(1, carrier MedicalCarrier1, planType PPO)
Detailed list of differences follows...
Context: Insurance<1>.employee-> Employee<1>.medicalInsurance-> Insurance<1>.insid
expected '1'
actual '11'
Context: Insurance<1>.employee-> Employee<1>.medicalInsurance-> Insurance<1>.carrier
expected 'MedicalCarrier1'
actual 'DentalCarrier1'
Context: Insurance<1>.employee-> Employee<1>.medicalInsurance-> MedicalInsurance<1>.planType
Expected not null, actual null
expected 'PPO'
actual 'null'
Expected this instance:
DentalInsurance(11, carrier DentalCarrier1, lifetimeOrthoBenefit 99.999)
Got persistent instance:
DentalInsurance(11, carrier DentalCarrier1, lifetimeOrthoBenefit 99.999)
Detailed list of differences follows...
Context: Insurance<11>.employee-> Employee<1>.medicalInsurance-> Insurance<1>.insid
expected '1'
actual '11'
Context: Insurance<11>.employee-> Employee<1>.medicalInsurance-> Insurance<1>.carrier
expected 'MedicalCarrier1'
actual 'DentalCarrier1'
Context: Insurance<11>.employee-> Employee<1>.medicalInsurance-> MedicalInsurance<1>.planType
Expected not null, actual null
expected 'PPO'
actual 'null'