Thanks a lot for this quick answer!
I will give it a try.
I am going to post what I have done that also give me the list of mapped fields:
Code:
@Test
public void testUsedAnnotations() {
outLn("testUsedAnnotations");
outLn("");
Annotation[] annotations = e.getClass().getAnnotations();
List<String> mappedColumns = new LinkedList();
String columnName;
Field[] fields = e.getClass().getDeclaredFields();
if (fields.length > 0) {
int fieldsLentgh = fields.length;
Annotation[] fieldAnnotations;
Column column;
for (int i = 0; i < fieldsLentgh; i++) {
outLn("Declared field:");
outLn(" " + fields[i].toString());
outLn(" annotations:" + fields[i].getAnnotations());
fieldAnnotations = fields[i].getDeclaredAnnotations();
int fieldAnnotationLength = fields[i].getDeclaredAnnotations().length;
if (fieldAnnotationLength > 0) {
for (int j = 0; j < fieldAnnotationLength; j++) {
outLn(" Filed Declared annotation:");
outLn(" Type:" + fieldAnnotations[j].annotationType());
if (fieldAnnotations[j].annotationType().getName().equals("javax.persistence.Column")){
column = (Column) fieldAnnotations[j];
columnName = column.name();
outLn(" column name: " + columnName);
mappedColumns.add(columnName.toUpperCase());
}
outLn("");
}
}
outLn("");
}
outLn("");
for (String sz : mappedColumns){
outLn(" " + sz);
}
} else {
outLn("--> There is no declared fields");
}
}