if ( StringUtils.isNotEmpty( jpoxMetadata.getIdentityType() ) )
{
String identityType = jpoxMetadata.getIdentityType();
if ( !IDENTITY_TYPES.contains( identityType ) )
{
throw new ModelloException( "The JDO mapping generator does not support the specified "
+ "class identity type '" + identityType + "'. " + "Supported types: "
+ IDENTITY_TYPES );
}
writer.addAttribute( "identity-type", identityType );
}
else if ( isInstantionApplicationType( modelClass ) )
{
writer.addAttribute( "identity-type", "application" );
}
}
else
{
needInheritance = true;
}
if ( objectIdClassOverride != null )
{
if ( StringUtils.isNotEmpty( objectIdClassOverride ) )
{
writer.addAttribute( "objectid-class", jpoxMetadata.getIdentityClass() );
}
}
else if ( StringUtils.isNotEmpty( jpoxMetadata.getIdentityClass() ) )
{
// Use user provided objectId class.
writer.addAttribute( "objectid-class", jpoxMetadata.getIdentityClass() );
}
else
{
// Calculate the objectId class.
List primaryKeys = getPrimaryKeyFields( modelClass );
// TODO: write generation support for multi-primary-key support.
// would likely need to write a java class that can supply an ObjectIdentity
// to the jpox/jdo implementation.
if ( primaryKeys.size() > 1 )
{
throw new ModelloException(
"The JDO mapping generator does not yet support Object Identifier generation "
+ "for the " + primaryKeys.size()
+ " fields specified as <identifier> or "
+ "with jpox.primary-key=\"true\"" );
}