mirror of https://github.com/apache/openjpa.git
OPENJPA-782: adding element-collection and collection-table
support for XML Serializer git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@727649 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5256a6c516
commit
90f6d5ff80
|
@ -39,6 +39,7 @@ import org.apache.openjpa.jdbc.meta.MappingInfo;
|
|||
import org.apache.openjpa.jdbc.meta.MappingRepository;
|
||||
import org.apache.openjpa.jdbc.meta.QueryResultMapping;
|
||||
import org.apache.openjpa.jdbc.meta.SequenceMapping;
|
||||
import org.apache.openjpa.jdbc.meta.ValueMappingImpl;
|
||||
import org.apache.openjpa.jdbc.meta.ValueMappingInfo;
|
||||
import org.apache.openjpa.jdbc.meta.strats.EnumValueHandler;
|
||||
import org.apache.openjpa.jdbc.meta.strats.FlatClassStrategy;
|
||||
|
@ -392,6 +393,27 @@ public class XMLPersistenceMappingSerializer
|
|||
endElement("join-table");
|
||||
}
|
||||
return;
|
||||
case ELEM_COLL:
|
||||
if (field.getMappingInfo().hasSchemaComponents()
|
||||
|| field.getElementMapping().getValueInfo()
|
||||
.hasSchemaComponents()) {
|
||||
String table = field.getMappingInfo().getTableName();
|
||||
if (table != null) {
|
||||
int index = table.indexOf('.');
|
||||
if (index < 0)
|
||||
addAttribute("name", table);
|
||||
else {
|
||||
addAttribute("schema", table.substring(0, index));
|
||||
addAttribute("name", table.substring(index + 1));
|
||||
}
|
||||
}
|
||||
startElement("collection-table");
|
||||
ValueMappingImpl elem = (ValueMappingImpl) field.getElement();
|
||||
serializeColumns(elem.getValueInfo(), ColType.COL,
|
||||
null);
|
||||
endElement("collection-table");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
serializeColumns(field.getValueInfo(), ColType.COL,
|
||||
|
|
|
@ -919,6 +919,11 @@ public class XMLPersistenceMetaDataSerializer
|
|||
strategy = "many-to-many";
|
||||
cascades = fmd.getElement();
|
||||
break;
|
||||
case ELEM_COLL:
|
||||
if (isMetaDataMode())
|
||||
addElementCollectionAttributes(fmd);
|
||||
strategy = "element-collection";
|
||||
break;
|
||||
}
|
||||
if (isMappingMode())
|
||||
addStrategyMappingAttributes(fmd);
|
||||
|
@ -1069,6 +1074,8 @@ public class XMLPersistenceMetaDataSerializer
|
|||
case JavaTypes.ARRAY:
|
||||
case JavaTypes.COLLECTION:
|
||||
case JavaTypes.MAP:
|
||||
if (fmd.isElementCollection())
|
||||
return PersistenceStrategy.ELEM_COLL;
|
||||
mappedBy = fmd.getMappedByMetaData();
|
||||
if (mappedBy == null || mappedBy.getTypeCode() != JavaTypes.PC)
|
||||
return PersistenceStrategy.MANY_MANY;
|
||||
|
@ -1133,6 +1140,16 @@ public class XMLPersistenceMetaDataSerializer
|
|||
addTargetEntityAttribute(fmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add element-collection attributes.
|
||||
*/
|
||||
private void addElementCollectionAttributes(FieldMetaData fmd)
|
||||
throws SAXException {
|
||||
if (fmd.isInDefaultFetchGroup())
|
||||
addAttribute("fetch", "EAGER");
|
||||
addTargetEntityAttribute(fmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a target-entity attribute to collection and map fields that do
|
||||
* not use generics.
|
||||
|
|
Loading…
Reference in New Issue