use of org.apache.openejb.jee.jpa.Transient in project tomee by apache.
the class CmpJpaConversion method mapFields.
/**
* Build a mapping between a bean's CMP fields and the
* particular subclass in the inheritance hierarchy that
* defines the field.
*
* @param clazz The bean implementation class.
* @param persistantFields The set of container-managed fields.
* @return A map of fieldname-to-defining class relationships.
*/
private Map<String, MappedSuperclass> mapFields(Class clazz, Set<String> persistantFields) {
persistantFields = new TreeSet<>(persistantFields);
final Map<String, MappedSuperclass> fields = new TreeMap<>();
// or we've reached the Object class.
while (!persistantFields.isEmpty() && !clazz.equals(Object.class)) {
// This is a single target for the relationship mapping for each
// class in the hierarchy.
final MappedSuperclass superclass = new MappedSuperclass(clazz.getName());
for (final Field field : clazz.getDeclaredFields()) {
if (!field.isSynthetic()) {
final String fieldName = field.getName();
// if this is one of bean's persistence fields, create the mapping
if (persistantFields.contains(fieldName)) {
fields.put(fieldName, superclass);
persistantFields.remove(fieldName);
} else if (!ENHANCED_FIELDS.contains(fieldName)) {
// these are fields we need to identify as transient for the persistence engine.
final Transient transientField = new Transient(fieldName);
superclass.addField(transientField);
}
}
}
clazz = clazz.getSuperclass();
}
return fields;
}
Aggregations