I wanted to know if there is a way to get all Entities classes and their metadata for a specific constant unit in JPA.
By metadata, I mean not only the fields, but also their column name, length, precision, data type, as well as the name of the table and everything I can get. I tried with a metamodel, but I think more for JPQL queries.
I need to show the user all active objects for some PU, and I donβt want to hardcode them in any array or in the database, I want the API to tell me what Entities have. And also, if possible, get managed instances for each object.
I think I could try using reflection to get all classes with @Entity annotation, but that would not be very pretty, and it would be harder to know what belongs to a particular PU, so if the api already provides this information it would be great .
I would prefer a JPA-compatible solution, but if that doesn't work, then the answer to this question will be answered in Hibernate or EclipseLink.
Thanks!
source share