EntityManagerFactory emf = Persistence.createEntityManagerFactory("myPersistenceUnit"); EntityManager em = emf.createEntityManager(); Metamodel metamodel = em.getMetamodel();
EntityManagerFactory emf = Persistence.createEntityManagerFactory("myPersistenceUnit"); EntityManager em = emf.createEntityManager(); Metamodel metamodel = em.getMetamodel(); EntityTypeThis example retrieves the metamodel for the persistence unit and gets the entity type for a Person entity. Then it gets all the singular attributes (i.e. not collections) of the Person entity. Library: This method is provided by the Java Persistence API (JPA) specification.person = metamodel.entity(Person.class); Set > attributes = person.getSingularAttributes();