// Remove generated fields from jdo model and mapping
// model before returning the result.
if (skipGeneratedFields) {
Iterator iter = mappingClasses.iterator();
while (iter.hasNext()) {
MappingClassElement mapClassElt = (MappingClassElement)iter.next();
if (mapClassElt != null) {
String className = mapClassElt.getName();
String ejbName = nameMapper.getEjbNameForPersistenceClass(
className);
PersistenceClassElement pce = (PersistenceClassElement)
model.getPersistenceClass(className);
PersistenceFieldElement[] allFields = pce.getFields();
if (allFields != null) {
List generatedFieldList = new ArrayList();
// In order to avoid concurrentmod exception,
// loop through all persistence fields to put generated
// fields in a list, loop though the list to remove
// the generated fields from the model.
for (int i = 0; i < allFields.length; i++) {
PersistenceFieldElement pfe = allFields[i];
if (pfe != null) {
String pFieldName = pfe.getName();
String ejbFieldName = nameMapper.
getEjbFieldForPersistenceField(className,
pFieldName);
if (nameMapper.isGeneratedField(ejbName,
ejbFieldName)) {
generatedFieldList.add(pfe);
}
}
}
// If the field is a version field, don't remove it
// from the model even though it is generated because
// it is needed to hold the version column information.
Iterator iterator = generatedFieldList.iterator();
while (iterator.hasNext()) {
PersistenceFieldElement pfe =
(PersistenceFieldElement)iterator.next();
MappingFieldElement mfe = mapClassElt.
getField(pfe.getName());
if (mfe != null && (!mfe.isVersion())) {
model.removeFieldElement(pfe);
mapClassElt.removeField(mfe);
}
}
}
}
}