|
Hard to follow the TCK test in terms of the data in each of the collections so I'll post my findings here so someone who understands the data that is trying to be persisted can comment. There are 2 fields of note in the CollectionCollections class : "CollectionOfSimpleClass42", and "CollectionOfSimpleClass3".
The former has embedded elements and the latter is unembedded, just having a FK to the SimpleClass table. Debugging suggests that both of these collections contains the same element(s). It's being encountered as part of the CollectionOfSimpleClass42 field and has a StateManager assigned (as an embedded object) and is persisted (into the join table). When JPOX gets around to persisting the CollectionOfSimpleClass3 field JPOX finds the already persistent SimpleClass element and so think it's ok to insert the join table row - hence the FK fails. Do these collections contain the same elements ? If so what are you expecting a JDO impl to do in this situation ? Make a copy of the PC object and persist that ? If so, please provide a reference to the section of the JDO2 spec defining such behaviour. Hi Andy,
Thanks for this analysis, Andy. This situation is not covered by the specification. So it's a test bug. Even if it were covered by the specification, I'd expect it to say that an exception should be thrown. The test case should not assign the same instance to both an embedded field and a non-embedded field. So the bug should be reassigned to Michelle. And we should look at all of the other collection test cases to make sure that this same situation isn't in the other tests. The spec does say it's ok to assign the same embedded instance to multiple fields, but as far as I know there's no test case for this. You might consider adding a JPOX check to make sure that when persisting a PC instance that is known to be embedded, then only embedded uses are permitted. Similarly, persisting a PC instance that is known to be non-embedded, then only non-embedded uses are permitted. Its the case of a PC instance being used as both embedded and non-embedded that's problematic, and if possible it would be nice to throw a different exception.
Michelle Caisse made changes - 27/Sep/05 01:31 AM
The collections tests in the fieldtypes package all obtain a single instance of a Vector for each datatype under test. So, there is only one Vector of SimpleClass instance that is reused for each CollectionOfSimpleClass element in CollectionCollections.
Currently values for Collections of Collection types are obtained as a Vector with one value for each different datatype represented in the fields of the class. Each field of the same data type is assigned the same instance from this Vector. org.apache.jdo.tck.models.fieldtypes.FirstSetOfTestValuesForCollection.java and ...SecondSetOfTestValuesForCollection.java each contain a vector field for each data type.
I propose removing these two classes from the repository, adding a static method to org.apache.jdo.tck.models.fieldtypes.TestUtil.java that takes the field data type and an integer specifying whether this is the first or second value as arguments, and returns a new Vector of new object instances on each invocation. TestCollectionCollections.java must also be modified to use the static method to get test values. Its checkValues() method must be modified to use a CollectionCollection type as the standard rather than using a FirstSetOfTestValuesForCollection or SecondSetOfTestValuesForCollection type as the standard. If we decide to go ahead with this change, all the other Test*Collection.java files will have to be changed as described. I would also address issues The attached patch shows the proposed changes for TestCollectionCollections.java and TestUtil.java only. Changes still need to be made to the other Test*Collections.java files.
Michelle Caisse made changes - 27/Sep/05 08:20 AM
Hi Michelle,
Your proposed patch looks good. The use of a new Vector for each request makes sense and avoids the issue of assigning the same persistent instance to both embedded and non-embedded collections. test\java\org\apache\jdo\tck\models\fieldtypes\FirstSetOfTestValuesForCollection.java
Michelle Caisse made changes - 29/Sep/05 04:04 AM
Michelle Caisse made changes - 01/Nov/05 06:39 AM
Reopened to set the Fix Version/s field to JDO 2 beta.
Michael Bouschen made changes - 23/Apr/06 03:08 AM
Michael Bouschen made changes - 23/Apr/06 03:10 AM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JDO-144.