*/
protected AbstractClassMetaData processClassAnnotations(PackageMetaData pmd, Class cls,
AnnotationObject[] annotations, ClassLoaderResolver clr)
{
this.clr = clr;
ClassMetaData cmd = null;
if (annotations != null && annotations.length > 0)
{
if (isClassPersistenceCapable(cls))
{
cmd = pmd.newClassMetadata(ClassUtils.getClassNameForClass(cls));
cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);
}
else if (isClassPersistenceAware(cls))
{
cmd = pmd.newClassMetadata(ClassUtils.getClassNameForClass(cls));
cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_AWARE);
}
if (cmd != null)
{
IdentityType identityType = IdentityType.APPLICATION;
String identityColumn = null;
String identityStrategy = null;
String identityGenerator = null;
String cacheable = "true";
String requiresExtent = "true";
String detachable = "true"; // In JPA default is true.
String embeddedOnly = "false";
String idClassName = null;
String catalog = null;
String schema = null;
String table = null;
String inheritanceStrategyForTree = null;
String inheritanceStrategy = null;
String discriminatorColumnName = null;
String discriminatorColumnType = null;
Integer discriminatorColumnLength = null;
String discriminatorColumnDdl = null;
String discriminatorValue = null;
String entityName = null;
Class[] entityListeners = null;
boolean excludeSuperClassListeners = false;
boolean excludeDefaultListeners = false;
ColumnMetaData[] pkColumnMetaData = null;
HashSet<UniqueMetaData> uniques = null;
HashSet<AbstractMemberMetaData> overriddenFields = null;
HashSet<QueryMetaData> namedQueries = null;
List<QueryResultMetaData> resultMappings = null;
FetchPlanMetaData[] fetchPlans = null;
FetchGroupMetaData[] fetchGroups = null;
HashSet<ExtensionMetaData> extensions = null;
String jpaLevel = mgr.getNucleusContext().getPersistenceConfiguration().getStringProperty("datanucleus.jpa.level");
for (int i=0;i<annotations.length;i++)
{
HashMap<String, Object> annotationValues = annotations[i].getNameValueMap();
String annName = annotations[i].getName();
if (annName.equals(JPAAnnotationUtils.ENTITY))
{
entityName = (String) annotationValues.get("name");
if (entityName == null || entityName.length() == 0)
{
entityName = ClassUtils.getClassNameForClass(cls);
}
}
else if (annName.equals(JPAAnnotationUtils.MAPPED_SUPERCLASS))
{
if (isClassPersistenceCapable(cls))
{
inheritanceStrategy = InheritanceStrategy.SUBCLASS_TABLE.toString();
}
}
else if (annName.equals(JPAAnnotationUtils.DATASTORE_IDENTITY) && jpaLevel.equalsIgnoreCase("DataNucleus"))
{
// extension to allow datastore-identity
identityType = IdentityType.DATASTORE;
identityColumn = (String)annotationValues.get("column");
GenerationType type = (GenerationType) annotationValues.get("generationType");
identityStrategy = JPAAnnotationUtils.getIdentityStrategyString(type);
identityGenerator = (String) annotationValues.get("generator");
}
else if (annName.equals(JPAAnnotationUtils.TABLE))
{
table = (String)annotationValues.get("name");
catalog = (String)annotationValues.get("catalog");
schema = (String)annotationValues.get("schema");
UniqueConstraint[] constrs = (UniqueConstraint[])annotationValues.get("uniqueConstraints");
if (constrs != null && constrs.length > 0)
{
for (int j=0;j<constrs.length;j++)
{
UniqueMetaData unimd = new UniqueMetaData();
unimd.setTable((String)annotationValues.get("name"));
for (int k=0;k<constrs[j].columnNames().length;k++)
{
ColumnMetaData colmd = new ColumnMetaData();
colmd.setName(constrs[j].columnNames()[k]);
unimd.addColumn(colmd);
}
if (uniques == null)
{
uniques = new HashSet<UniqueMetaData>();
}
uniques.add(unimd);
}
}
}
else if (annName.equals(JPAAnnotationUtils.ID_CLASS))
{
idClassName = ((Class)annotationValues.get("value")).getName();
}
else if (annName.equals(JPAAnnotationUtils.INHERITANCE))
{
// Only valid in the root class
InheritanceType inhType = (InheritanceType)annotationValues.get("strategy");
inheritanceStrategyForTree = inhType.toString();
if (inhType == InheritanceType.JOINED)
{
inheritanceStrategy = InheritanceStrategy.NEW_TABLE.toString();
}
else if (inhType == InheritanceType.TABLE_PER_CLASS)
{
inheritanceStrategy = InheritanceStrategy.COMPLETE_TABLE.toString();
}
else if (inhType == InheritanceType.SINGLE_TABLE)
{
// Translated to root class as "new-table" and children as "superclass-table"
// and @Inheritance should only be specified on root class so defaults to internal default
}
}
else if (annName.equals(JPAAnnotationUtils.DISCRIMINATOR_COLUMN))
{
discriminatorColumnName = (String)annotationValues.get("name");
DiscriminatorType type = (DiscriminatorType)annotationValues.get("discriminatorType");
if (type == DiscriminatorType.CHAR)
{
discriminatorColumnType = "CHAR";
}
else if (type == DiscriminatorType.INTEGER)
{
discriminatorColumnType = "INTEGER";
}
else if (type == DiscriminatorType.STRING)
{
discriminatorColumnType = "VARCHAR";
}
discriminatorColumnLength = (Integer)annotationValues.get("length");
String tmp = (String)annotationValues.get("columnDefinition");
if (!StringUtils.isWhitespace(tmp))
{
discriminatorColumnDdl = tmp;
}
}
else if (annName.equals(JPAAnnotationUtils.DISCRIMINATOR_VALUE))
{
discriminatorValue = (String)annotationValues.get("value");
}
else if (annName.equals(JPAAnnotationUtils.EMBEDDABLE))
{
embeddedOnly = "true";
identityType = IdentityType.NONDURABLE;
}
else if (annName.equals(JPAAnnotationUtils.CACHEABLE))
{
Boolean cacheableVal = (Boolean)annotationValues.get("value");
if (cacheableVal == Boolean.FALSE)
{
cacheable = "false";
}
}
else if (annName.equals(JPAAnnotationUtils.ENTITY_LISTENERS))
{
entityListeners = (Class[])annotationValues.get("value");
}
else if (annName.equals(JPAAnnotationUtils.EXCLUDE_SUPERCLASS_LISTENERS))
{
excludeSuperClassListeners = true;
}
else if (annName.equals(JPAAnnotationUtils.EXCLUDE_DEFAULT_LISTENERS))
{
excludeDefaultListeners = true;
}
else if (annName.equals(JPAAnnotationUtils.SEQUENCE_GENERATOR))
{
processSequenceGeneratorAnnotation(pmd, annotationValues);
}
else if (annName.equals(JPAAnnotationUtils.TABLE_GENERATOR))
{
processTableGeneratorAnnotation(pmd, annotationValues);
}
else if (annName.equals(JPAAnnotationUtils.PRIMARY_KEY_JOIN_COLUMN))
{
// Override the PK column name when we have a persistent superclass
pkColumnMetaData = new ColumnMetaData[1];
pkColumnMetaData[0] = new ColumnMetaData();
pkColumnMetaData[0].setName((String)annotationValues.get("name"));
pkColumnMetaData[0].setTarget((String)annotationValues.get("referencedColumnName"));
}
else if (annName.equals(JPAAnnotationUtils.PRIMARY_KEY_JOIN_COLUMNS))
{
// Override the PK column names when we have a persistent superclass
PrimaryKeyJoinColumn[] values = (PrimaryKeyJoinColumn[])annotationValues.get("value");
pkColumnMetaData = new ColumnMetaData[values.length];
for (int j=0;j<values.length;j++)
{
pkColumnMetaData[j] = new ColumnMetaData();
pkColumnMetaData[j].setName(values[j].name());
pkColumnMetaData[j].setTarget(values[j].referencedColumnName());
if (!StringUtils.isWhitespace(values[j].columnDefinition()))
{
pkColumnMetaData[j].setColumnDdl(values[j].columnDefinition());
}
}
}
else if (annName.equals(JPAAnnotationUtils.ATTRIBUTE_OVERRIDES))
{
AttributeOverride[] overrides = (AttributeOverride[])annotationValues.get("value");
if (overrides != null)
{
if (overriddenFields == null)
{
overriddenFields = new HashSet<AbstractMemberMetaData>();
}
for (int j=0;j<overrides.length;j++)
{
AbstractMemberMetaData fmd = new FieldMetaData(cmd,
"#UNKNOWN." + overrides[j].name());
fmd.setPersistenceModifier(FieldPersistenceModifier.PERSISTENT.toString());
Column col = overrides[j].column();
// TODO Make inferrals about jdbctype, length etc if the field is 1 char etc
ColumnMetaData colmd = new ColumnMetaData();
colmd.setName(col.name());
colmd.setLength(col.length());
colmd.setScale(col.scale());
colmd.setAllowsNull(col.nullable());
colmd.setInsertable(col.insertable());
colmd.setUpdateable(col.updatable());
colmd.setUnique(col.unique());
fmd.addColumn(colmd);
overriddenFields.add(fmd);
}
}
}
else if (annName.equals(JPAAnnotationUtils.ATTRIBUTE_OVERRIDE))
{
if (overriddenFields == null)
{
overriddenFields = new HashSet<AbstractMemberMetaData>();
}
AbstractMemberMetaData fmd = new FieldMetaData(cmd,
"#UNKNOWN." + (String)annotationValues.get("name"));
Column col = (Column)annotationValues.get("column");
// TODO Make inferrals about jdbctype, length etc if the field is 1 char etc
ColumnMetaData colmd = new ColumnMetaData();
colmd.setName(col.name());
colmd.setLength(col.length());
colmd.setScale(col.scale());
colmd.setAllowsNull(col.nullable());
colmd.setInsertable(col.insertable());
colmd.setUpdateable(col.updatable());
colmd.setUnique(col.unique());
fmd.addColumn(colmd);
overriddenFields.add(fmd);
}
else if (annName.equals(JPAAnnotationUtils.ASSOCIATION_OVERRIDES))
{
AssociationOverride[] overrides = (AssociationOverride[])annotationValues.get("value");
if (overrides != null)
{
if (overriddenFields == null)
{
overriddenFields = new HashSet<AbstractMemberMetaData>();
}
for (int j=0;j<overrides.length;j++)
{
AbstractMemberMetaData fmd = new FieldMetaData(cmd,
"#UNKNOWN." + overrides[j].name());
JoinColumn[] cols = overrides[j].joinColumns();
for (int k=0;k<cols.length;k++)
{
ColumnMetaData colmd = new ColumnMetaData();
colmd.setName(cols[k].name());
colmd.setTarget(cols[k].referencedColumnName());
colmd.setAllowsNull(cols[k].nullable());
colmd.setInsertable(cols[k].insertable());
colmd.setUpdateable(cols[k].updatable());
colmd.setUnique(cols[k].unique());
fmd.addColumn(colmd);
}
overriddenFields.add(fmd);
}
}
}
else if (annName.equals(JPAAnnotationUtils.ASSOCIATION_OVERRIDE))
{
if (overriddenFields == null)
{
overriddenFields = new HashSet<AbstractMemberMetaData>();
}
AbstractMemberMetaData fmd = new FieldMetaData(cmd,
"#UNKNOWN." + (String)annotationValues.get("name"));
JoinColumn[] cols = (JoinColumn[])annotationValues.get("joinColumns");
for (int k=0;k<cols.length;k++)
{
ColumnMetaData colmd = new ColumnMetaData();
colmd.setName(cols[k].name());
colmd.setTarget(cols[k].referencedColumnName());
colmd.setAllowsNull(cols[k].nullable());
colmd.setInsertable(cols[k].insertable());
colmd.setUpdateable(cols[k].updatable());
colmd.setUnique(cols[k].unique());
fmd.addColumn(colmd);
}
overriddenFields.add(fmd);
}
else if (annName.equals(JPAAnnotationUtils.NAMED_QUERIES))
{
NamedQuery[] queries = (NamedQuery[])annotationValues.get("value");
if (namedQueries == null)
{
namedQueries = new HashSet<QueryMetaData>();
}
for (int j=0;j<queries.length;j++)
{
QueryMetaData qmd = new QueryMetaData(queries[j].name());
qmd.setLanguage(QueryLanguage.JPQL.toString());
qmd.setUnmodifiable(true);
qmd.setQuery(queries[j].query());
namedQueries.add(qmd);
}
}
else if (annName.equals(JPAAnnotationUtils.NAMED_QUERY))
{
if (namedQueries == null)
{
namedQueries = new HashSet<QueryMetaData>();
}
QueryMetaData qmd = new QueryMetaData((String)annotationValues.get("name"));
qmd.setLanguage(QueryLanguage.JPQL.toString());
qmd.setUnmodifiable(true);
qmd.setQuery((String)annotationValues.get("query"));
namedQueries.add(qmd);
}
else if (annName.equals(JPAAnnotationUtils.NAMED_NATIVE_QUERIES))
{
NamedNativeQuery[] queries = (NamedNativeQuery[])annotationValues.get("value");
if (namedQueries == null)
{
namedQueries = new HashSet<QueryMetaData>();
}
for (int j=0;j<queries.length;j++)
{
String resultClassName = null;
if (queries[j].resultClass() != null && queries[j].resultClass() != void.class)
{
resultClassName = queries[j].resultClass().getName();
}
String resultMappingName = null;
if (queries[j].resultSetMapping() != null)
{
resultMappingName = queries[j].resultSetMapping();
}
QueryMetaData qmd = new QueryMetaData(queries[j].name());
qmd.setLanguage(QueryLanguage.SQL.toString());
qmd.setUnmodifiable(true);
qmd.setResultClass(resultClassName);
qmd.setResultMetaDataName(resultMappingName);
qmd.setQuery(queries[j].query());
namedQueries.add(qmd);
}
}
else if (annName.equals(JPAAnnotationUtils.NAMED_NATIVE_QUERY))
{
if (namedQueries == null)
{
namedQueries = new HashSet<QueryMetaData>();
}
Class resultClass = (Class)annotationValues.get("resultClass");
String resultClassName = null;
if (resultClass != null && resultClass != void.class)
{
resultClassName = resultClass.getName();
}
String resultMappingName = (String)annotationValues.get("resultSetMapping");
if (StringUtils.isWhitespace(resultMappingName))
{
resultMappingName = null;
}
QueryMetaData qmd = new QueryMetaData((String)annotationValues.get("name"));
qmd.setLanguage(QueryLanguage.SQL.toString());
qmd.setUnmodifiable(true);
qmd.setResultClass(resultClassName);
qmd.setResultMetaDataName(resultMappingName);
qmd.setQuery((String)annotationValues.get("query"));
namedQueries.add(qmd);
}
else if (annName.equals(JPAAnnotationUtils.SQL_RESULTSET_MAPPINGS))
{
SqlResultSetMapping[] mappings = (SqlResultSetMapping[])annotationValues.get("value");
if (resultMappings == null)
{
resultMappings = new ArrayList<QueryResultMetaData>();
}
for (int j=0;j<mappings.length;j++)
{
QueryResultMetaData qrmd = new QueryResultMetaData(mappings[j].name());
EntityResult[] entityResults = (EntityResult[])mappings[j].entities();
if (entityResults != null)
{
for (int k=0;k<entityResults.length;k++)
{
String entityClassName = entityResults[k].entityClass().getName();
qrmd.addPersistentTypeMapping(entityClassName, null,
entityResults[k].discriminatorColumn());
FieldResult[] fields = entityResults[k].fields();
if (fields != null)
{
for (int l=0;l<fields.length;l++)
{
qrmd.addMappingForPersistentTypeMapping(entityClassName, fields[l].name(), fields[l].column());
}
}
}
}
ColumnResult[] colResults = (ColumnResult[])mappings[j].columns();
if (colResults != null)
{
for (int k=0;k<colResults.length;k++)
{
qrmd.addScalarColumn(colResults[k].name());
}
}
resultMappings.add(qrmd);
}
}
else if (annName.equals(JPAAnnotationUtils.SQL_RESULTSET_MAPPING))
{
if (resultMappings == null)
{
resultMappings = new ArrayList<QueryResultMetaData>();
}
QueryResultMetaData qrmd = new QueryResultMetaData((String)annotationValues.get("name"));
EntityResult[] entityResults = (EntityResult[])annotationValues.get("entities");
if (entityResults != null)
{
for (int j=0;j<entityResults.length;j++)
{
String entityClassName = entityResults[j].entityClass().getName();
qrmd.addPersistentTypeMapping(entityClassName, null,
entityResults[j].discriminatorColumn());
FieldResult[] fields = entityResults[j].fields();
if (fields != null)
{
for (int k=0;k<fields.length;k++)
{
qrmd.addMappingForPersistentTypeMapping(entityClassName, fields[k].name(), fields[k].column());
}
}
}
}
ColumnResult[] colResults = (ColumnResult[])annotationValues.get("columns");
if (colResults != null)
{
for (int j=0;j<colResults.length;j++)
{
qrmd.addScalarColumn(colResults[j].name());
}
}
resultMappings.add(qrmd);
}
else if (annName.equals(JPAAnnotationUtils.SECONDARY_TABLES))
{
// processed below in newJoinMetaData
}
else if (annName.equals(JPAAnnotationUtils.SECONDARY_TABLE))
{
// processed below in newJoinMetaData
}
else if (annName.equals(JPAAnnotationUtils.FETCHPLANS))
{
if (fetchPlans != null)
{
NucleusLogger.METADATA.warn(LOCALISER.msg("044207", cmd.getFullClassName()));
}
FetchPlan[] plans = (FetchPlan[])annotationValues.get("value");
fetchPlans = new FetchPlanMetaData[plans.length];
for (int j=0;j<plans.length;j++)
{
fetchPlans[j] = new FetchPlanMetaData(plans[j].name());
fetchPlans[j].setMaxFetchDepth(plans[j].maxFetchDepth());
fetchPlans[j].setFetchSize(plans[j].fetchSize());
int numGroups = plans[j].fetchGroups().length;
for (int k=0;k<numGroups;k++)
{
FetchGroupMetaData fgmd = new FetchGroupMetaData(plans[j].fetchGroups()[k]);
fetchPlans[j].addFetchGroup(fgmd);
}
}
}
else if (annName.equals(JPAAnnotationUtils.FETCHPLAN))
{
if (fetchPlans != null)
{
NucleusLogger.METADATA.warn(LOCALISER.msg("044207", cmd.getFullClassName()));
}
fetchPlans = new FetchPlanMetaData[1];
int maxFetchDepth = ((Integer)annotationValues.get("maxFetchDepth")).intValue();
int fetchSize = ((Integer)annotationValues.get("fetchSize")).intValue();
fetchPlans[0] = new FetchPlanMetaData((String)annotationValues.get("name"));
fetchPlans[0].setMaxFetchDepth(maxFetchDepth);
fetchPlans[0].setFetchSize(fetchSize);
}
else if (annName.equals(JPAAnnotationUtils.FETCHGROUPS))
{
if (fetchGroups != null)
{
NucleusLogger.METADATA.warn(LOCALISER.msg("044208", cmd.getFullClassName()));
}
FetchGroup[] groups = (FetchGroup[])annotationValues.get("value");
fetchGroups = new FetchGroupMetaData[groups.length];
for (int j=0;j<groups.length;j++)
{
fetchGroups[j] = new FetchGroupMetaData(groups[j].name());
fetchGroups[j].setPostLoad(groups[j].postLoad());
int numFields = groups[j].members().length;
for (int k=0;k<numFields;k++)
{
FieldMetaData fmd = new FieldMetaData(fetchGroups[j],
groups[j].members()[k].value());
fmd.setRecursionDepth(groups[j].members()[k].recursionDepth());
fetchGroups[j].addMember(fmd);
}
int numGroups = groups[j].fetchGroups().length;
for (int k=0;k<numGroups;k++)
{
FetchGroupMetaData subgrp = new FetchGroupMetaData(groups[j].fetchGroups()[k]);
fetchGroups[j].addFetchGroup(subgrp);
}
}
}
else if (annName.equals(JPAAnnotationUtils.FETCHGROUP))
{
if (fetchGroups != null)
{
NucleusLogger.METADATA.warn(LOCALISER.msg("044208", cmd.getFullClassName()));
}
fetchGroups = new FetchGroupMetaData[1];
fetchGroups[0] = new FetchGroupMetaData((String)annotationValues.get("name"));
fetchGroups[0].setPostLoad((String)annotationValues.get("postLoad"));
FetchMember[] fields = (FetchMember[])annotationValues.get("members");
if (fields != null)
{
for (int j=0;j<fields.length;j++)
{
FieldMetaData fmd = new FieldMetaData(fetchGroups[0],
fields[j].value());
fmd.setRecursionDepth(fields[j].recursionDepth());
fetchGroups[0].addMember(fmd);
}
}
}
else if (annName.equals(JPAAnnotationUtils.EXTENSION))
{
// extension
ExtensionMetaData extmd = new ExtensionMetaData((String)annotationValues.get("vendorName"),
(String)annotationValues.get("key"), (String)annotationValues.get("value"));
if (extensions == null)
{
extensions = new HashSet<ExtensionMetaData>(1);
}
extensions.add(extmd);
}
else if (annName.equals(JPAAnnotationUtils.EXTENSIONS))
{
// extension
Extension[] values = (Extension[])annotationValues.get("value");
if (values != null && values.length > 0)
{
if (extensions == null)
{
extensions = new HashSet<ExtensionMetaData>(values.length);
}
for (int j=0;j<values.length;j++)
{
ExtensionMetaData extmd = new ExtensionMetaData(values[j].vendorName(),
values[j].key().toString(), values[j].value().toString());
extensions.add(extmd);
}
}
}
else
{
NucleusLogger.METADATA.error(LOCALISER.msg("044203",
cls.getName(), annotations[i].getName()));
}
}
if (entityName == null || entityName.length() == 0)
{
entityName = ClassUtils.getClassNameForClass(cls);
}
NucleusLogger.METADATA.info(LOCALISER.msg("044200", cls.getName(), "JPA"));
cmd.setTable(table);
cmd.setCatalog(catalog);
cmd.setSchema(schema);
cmd.setEntityName(entityName);
cmd.setDetachable(detachable);
cmd.setRequiresExtent(requiresExtent);
cmd.setObjectIdClass(idClassName);
cmd.setEmbeddedOnly(embeddedOnly);
cmd.setCacheable(cacheable);
cmd.setIdentityType(identityType);
if (isClassPersistenceCapable(cls.getSuperclass()))
{
cmd.setPersistenceCapableSuperclass(cls.getSuperclass().getName());
}
if (excludeSuperClassListeners)
{
cmd.excludeSuperClassListeners();
}
if (excludeDefaultListeners)
{
cmd.excludeDefaultListeners();
}
if (entityListeners != null)
{
for (int i=0; i<entityListeners.length; i++)
{
// Any EventListener will not have their callback methods registered at this point
EventListenerMetaData elmd = new EventListenerMetaData(entityListeners[i].getName());
cmd.addListener(elmd);
}
}
// Inheritance
InheritanceMetaData inhmd = null;
if (inheritanceStrategy != null)
{
// Strategy specified so create inheritance data
inhmd = cmd.newInheritanceMetadata().setStrategy(inheritanceStrategy);
inhmd.setStrategyForTree(inheritanceStrategyForTree);
}
else if (discriminatorValue != null || discriminatorColumnName != null ||
discriminatorColumnLength != null || discriminatorColumnType != null)
{
// Discriminator specified so we need inheritance data
inhmd = cmd.newInheritanceMetadata().setStrategyForTree(inheritanceStrategyForTree);
}
if (discriminatorValue != null || discriminatorColumnName != null ||
discriminatorColumnLength != null || discriminatorColumnType != null)
{
// Add discriminator information to the inheritance of this class
DiscriminatorMetaData dismd = inhmd.newDiscriminatorMetadata();
if (discriminatorValue != null)
{
// Value specified so assumed to be value-map
dismd.setColumnName(discriminatorColumnName);
dismd.setValue(discriminatorValue).setStrategy("value-map").setIndexed("false");
}
else
{
// No value so use class-name
discriminatorValue = cls.getName();
dismd.setColumnName(discriminatorColumnName);
dismd.setValue(discriminatorValue).setStrategy("value-map").setIndexed("false");
}
ColumnMetaData discolmd = null;
if (discriminatorColumnLength != null || discriminatorColumnName != null || discriminatorColumnType != null)
{
discolmd = new ColumnMetaData();
discolmd.setName(discriminatorColumnName);
if (discriminatorColumnType != null)
{
discolmd.setJdbcType(discriminatorColumnType);
}
if (discriminatorColumnLength != null)
{
discolmd.setLength(discriminatorColumnLength);
}
dismd.setColumnMetaData(discolmd);
if (discriminatorColumnDdl != null)
{
discolmd.setColumnDdl(discriminatorColumnDdl);
}
}
}
// extension - datastore-identity
if (identityType == IdentityType.DATASTORE)
{
IdentityMetaData idmd = cmd.newIdentityMetadata();
idmd.setColumnName(identityColumn);
idmd.setValueStrategy(IdentityStrategy.getIdentityStrategy(identityStrategy));
if (identityGenerator != null)
{
idmd.setSequence(identityGenerator);
idmd.setValueGeneratorName(identityGenerator);
}
}
if (pkColumnMetaData != null)
{
// PK columns overriding those in the root class
PrimaryKeyMetaData pkmd = cmd.newPrimaryKeyMetadata();
for (int i=0;i<pkColumnMetaData.length;i++)
{
pkmd.addColumn(pkColumnMetaData[i]);
}
}
if (uniques != null && uniques.size() > 0)
{
// Unique constraints for the primary/secondary tables
Iterator<UniqueMetaData> uniquesIter = uniques.iterator();
while (uniquesIter.hasNext())
{
cmd.addUniqueConstraint(uniquesIter.next());
}
}
if (overriddenFields != null)
{
// Fields overridden from superclasses
Iterator<AbstractMemberMetaData> iter = overriddenFields.iterator();
while (iter.hasNext())
{
cmd.addMember(iter.next());
}
}
if (namedQueries != null)
{
Iterator<QueryMetaData> iter = namedQueries.iterator();
while (iter.hasNext())
{
cmd.addQuery(iter.next());
}
}
if (resultMappings != null)
{
Iterator<QueryResultMetaData> iter = resultMappings.iterator();
while (iter.hasNext())
{
cmd.addQueryResultMetaData(iter.next());
}
}
if (extensions != null)
{
Iterator<ExtensionMetaData> iter = extensions.iterator();
while (iter.hasNext())
{
ExtensionMetaData extmd = iter.next();
cmd.addExtension(extmd.getVendorName(), extmd.getKey(), extmd.getValue());
}
}
}
// Process any secondary tables