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))