+ "with jpox.primary-key=\"true\"" );
}
if ( primaryKeys.size() == 1 )
{
ModelField modelField = (ModelField) primaryKeys.get( 0 );
String objectIdClass = (String) PRIMITIVE_IDENTITY_MAP.get( modelField.getType() );
if ( StringUtils.isNotEmpty( objectIdClass ) )
{
writer.addAttribute( "objectid-class", objectIdClass );
}
}
}
if ( needInheritance )
{
writer.startElement( "inheritance" );
// TODO: The table strategy should be customizable
// http://www.jpox.org/docs/1_1/inheritance.html - in particular
// the strategy="subclass-table" and strategy="new-table" parts
writer.addAttribute( "strategy", "new-table" );
writer.endElement();
}
// ----------------------------------------------------------------------
// Write all fields
// ----------------------------------------------------------------------
for ( Iterator it = fields.iterator(); it.hasNext(); )
{
ModelField modelField = (ModelField) it.next();
writeModelField( writer, modelField );
}
// Write ignored fields.
List ignoredFields = jpoxMetadata.getNotPersisted();
if ( ignoredFields != null )
{
Iterator it = ignoredFields.iterator();
while ( it.hasNext() )
{
String fieldName = (String) it.next();
writer.startElement( "field" );
writer.addAttribute( "name", fieldName );
writer.addAttribute( "persistence-modifier", "none" );
writer.endElement();
}
}
// ----------------------------------------------------------------------
// Write out the "detailed" fetch group. This group will by default
// contain all fields in a object. The default fetch group will contain
// all the primitives in a class as by JDO defaults.
// ----------------------------------------------------------------------
List detailedFields = new ArrayList();
for ( Iterator it = fields.iterator(); it.hasNext(); )
{
ModelField field = (ModelField) it.next();
if ( field.isPrimitive() )
{
continue;
}
if ( field instanceof ModelAssociation )
{
StoreAssociationMetadata storeMetadata = getAssociationMetadata( (ModelAssociation) field );
if ( storeMetadata.isPart() != null && storeMetadata.isPart().booleanValue() )
{
continue;
}
}
detailedFields.add( field );
}
// ----------------------------------------------------------------------
// Write all fetch groups
// ----------------------------------------------------------------------
// Write defaut detail fetch group
writeFetchGroup( writer, modelClass.getName() + "_detail", detailedFields, true );
// Write user fetch groups
Map fetchsMap = new HashMap();
for ( Iterator it = fields.iterator(); it.hasNext(); )
{
ModelField field = (ModelField) it.next();
JPoxFieldMetadata jpoxFieldMetadata = (JPoxFieldMetadata) field.getMetadata( JPoxFieldMetadata.ID );
List names = jpoxFieldMetadata.getFetchGroupNames();
if ( names != null )
{