|
[
Permlink
| « Hide
]
Gokhan Ergul added a comment - 14/Feb/07 12:04 PM
Test case and trace output attached.
0.9.7-snapshot seems to have solved this indeed, thanks.
Alright, it did manifest itself in a different way as you guessed:
java.lang.NullPointerException at org.apache.openjpa.jdbc.meta.strats.EmbedValueHandler.map(EmbedValueHandler.java:50) at org.apache.openjpa.jdbc.meta.strats.ObjectIdValueHandler.map(ObjectIdValueHandler.java:46) at org.apache.openjpa.jdbc.meta.strats.HandlerStrategies.map(HandlerStrategies.java:56) at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.map(HandlerFieldStrategy.java:77) at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:117) ... Bit of debugging into the code: (EmbedValueHandler.java) protected void map(ValueMapping vm, String name, ColumnIO io, boolean adapt, List cols, List args) { // have to resolve embedded value to collect its columns vm.getEmbeddedMapping().resolve(vm.MODE_META | vm.MODE_MAPPING); ... vm .getEmbeddedMapping() returns null, since: (ValueMetaDataImpl.java) public ClassMetaData getEmbeddedMetaData() { if (_embeddedMeta == null && isEmbeddedPC()) addEmbeddedMetaData(); return _embeddedMeta; } and public boolean isEmbeddedPC() { return _decCode == JavaTypes.PC && isEmbedded(); } _decCode is JavaTypes.OID. JavaTypes.PC was possibly overwritten by: public boolean resolve(int mode) { ... // oid as primary key field? if (_decCode == JavaTypes.PC && isEmbedded() && _owner.isPrimaryKey() && _owner.getValue() == this) _code = _decCode = JavaTypes.OID; So I've changed public boolean isEmbeddedPC() { return _decCode == JavaTypes.PC && isEmbedded(); } to public boolean isEmbeddedPC() { return (_decCode == JavaTypes.PC || _decCode == JavaTypes.OID) && isEmbedded(); } seems to have fixed the problem, tho I'm not sure if it has any nasty sideeffects. Any comments? Cancel my previous comment. Embedded PCs are handled very differently than OIDs at runtime, and so changing the isEmbeddedPC method to encompass OIDs as well might cause problems. I think the root of the problem has to do with metadata resolution of mapped superclass fields (after all, EmbeddedIds in Entities work fine, just not in MappedSuperclasses). I'll investigate further.
Resolved with revision 509632. When copying OID superclass fields for mapping in a subclass, revert the type of the field to PC. It will re-resolve to OID when the copied field's metadata is resolved, and in the meantime it ensures that the copied field resolution will use the same code path as non-copied fields.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||