return metaData.getIdMethod().invoke(value);
} else if (metaData.getIdField() != null) {
return metaData.getIdField().get(value);
}
} catch (IllegalArgumentException iae) {
throw new ProcessEngineException("Illegal argument exception when getting value from id method/field on JPAEntity", iae);
} catch (IllegalAccessException iae) {
throw new ProcessEngineException("Cannot access id method/field for JPA Entity", iae);
} catch (InvocationTargetException ite) {
throw new ProcessEngineException("Exception occured while getting value from id field/method on JPAEntity: " +
ite.getCause().getMessage(), ite.getCause());
}
// Fall trough when no method and field is set
throw new ProcessEngineException("Cannot get id from JPA Entity, no id method/field set");
}