use of javax.jdo.metadata.FieldMetadata in project motech by motech.
the class EntityMetadataBuilderImpl method addIdField.
private void addIdField(ClassMetadata cmd, String className, Class<?> definition) {
boolean containsID;
boolean isBaseClass;
try {
CtClass ctClass = MotechClassPool.getDefault().getOrNull(className);
containsID = null != ctClass && null != ctClass.getField(ID_FIELD_NAME);
isBaseClass = null != ctClass && (null == ctClass.getSuperclass() || Object.class.getName().equalsIgnoreCase(ctClass.getSuperclass().getName()));
} catch (NotFoundException e) {
containsID = false;
isBaseClass = false;
}
if (containsID && isBaseClass) {
FieldMetadata metadata = cmd.newFieldMetadata(ID_FIELD_NAME);
metadata.setValueStrategy(getIdGeneratorStrategy(metadata, definition));
metadata.setPrimaryKey(true);
}
}
Aggregations