Via reflection I have found a lists of properties from x POJO classes which I need to display and also created a list of headings for which I will display the properties under(headings are from annotations on the fields).
The form of the POJO is that for each property I wish to display there is a getter.
Here are the details: The POJO’s are annotated with @Entity, I am executing a query (using JPA) and getting a result set. I now want to display the result set (a collection of a particular POJO) by calling the correct getters.
I can call the getters. My issue is having not done this… I worry that using reflection may not be particularly efficient on large result sets and perhaps there is a way to make JPA entity objects iterable in consistent way.
For instance if there an easy way to return each record as an indexable collection then I can just line up my headers in the order they would appear in each record and iterate. This then would not be a POJO but with encapsulation it could look that way in a part of the API.
Looking for suggestions! It will work one way or another but I would rather it be pretty.
Since you are using JPA, have you tried the JPA 2 metamodel (javax.persistence.metamodel). This will give you information about your JPA entities from the JPA metadata: