0

If there is a jaxb object with the following:

@Persist
@ColumnMapping(columnName = "foo_bar")
protected String fooBar;

Is there a way to retrieve the column name 'foo_bar' in my Java code somehow using 'fooBar' without changing the jaxb object?

Mankind1023
  • 7,198
  • 16
  • 56
  • 86
  • 1
    I guess it would be something in this direction -> https://stackoverflow.com/questions/20192552/get-value-of-a-parameter-of-an-annotation-in-java :/ Couldn't find anything relative to your question in JaxB docs. – dbl Aug 10 '20 at 14:31
  • Now I see that the annotations that you use aren't part of JaxB. Is that your data model? Check this tread maybe: https://stackoverflow.com/questions/2023700/get-column-name-of-property-mapped-with-hibernate – dbl Aug 10 '20 at 14:45
  • Thanks, I got it to work with entity.getClass().getDeclaredField("fooBar").getAnnotation(some.path.annotations.ColumnMapping.class).columnName(); (it can be cleaned up obviously, but the basic idea works) – Mankind1023 Aug 10 '20 at 16:26
  • Really dislike this approach but you can't do much more since you have no control on the domain models. – dbl Aug 11 '20 at 07:26

0 Answers0