Retrieving JPA Entity List and metadata

旧时模样 提交于 2019-12-04 04:56:47
Meiyappan Kannappa

Yes you can get all the entities and the corresponding meta data information about the enitities from EntityManager.

EntityManager.getMetamodel() will give you access to the Metamodel interface from where you can access EntityType and ManagedType to get the attributes of the entity.

Entities are independent of any persistence unit when they are defined. They are associated with a persistence unit in its definition, in persistence.xml. EntityManagerFactory that manages the entity managers for a given persistent unit doesn't seem to have any API to get the list of entities it manages. SessionFactory of Hibernate, counterpart of EntityManagerFactory, does have APIs to get hold of the class metadata (http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/SessionFactory.html).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!