private Type getRelationType(final Entity businessObject, final String methodName) throws SBusinessDataRepositoryException { final String fieldName = ClassReflector.getFieldName(methodName); Annotation[] annotations; try { annotations = businessObject.getClass().getDeclaredField(fieldName).getAnnotations(); } catch (final NoSuchFieldException e) { return null; } catch (final SecurityException e) { throw new SBusinessDataRepositoryException(e); } for (final Annotation annotation : annotations) { final Set<Class<? extends Annotation>> annotationKeySet = getAnnotationKeySet(); if (annotationKeySet.contains(annotation.annotationType())) { try { final Method cascade = annotation.getClass().getMethod("cascade"); final CascadeType[] cascadeTypes = (CascadeType[]) cascade.invoke(annotation); if (CascadeType.MERGE.equals(cascadeTypes[0])) { return Type.AGGREGATION; } if (CascadeType.ALL.equals(cascadeTypes[0])) { return Type.COMPOSITION; } } catch (final Exception e) { throw new SBusinessDataRepositoryException(e); } } } return null; }
private Type getRelationType(final Entity businessObject, final String methodName) throws SBusinessDataRepositoryException { final String fieldName = ClassReflector.getFieldName(methodName); Annotation[] annotations; try { annotations = businessObject.getClass().getDeclaredField(fieldName).getAnnotations(); } catch (final NoSuchFieldException e) { return null; } catch (final SecurityException e) { throw new SBusinessDataRepositoryException(e); } for (final Annotation annotation : annotations) { final Set<Class<? extends Annotation>> annotationKeySet = getAnnotationKeySet(); if (annotationKeySet.contains(annotation.annotationType())) { try { final Method cascade = annotation.getClass().getMethod("cascade"); final CascadeType[] cascadeTypes = (CascadeType[]) cascade.invoke(annotation); if (CascadeType.MERGE.equals(cascadeTypes[0])) { return Type.AGGREGATION; } if (CascadeType.ALL.equals(cascadeTypes[0])) { return Type.COMPOSITION; } } catch (final Exception e) { throw new SBusinessDataRepositoryException(e); } } } return null; }