0

My project uses hibernate 5 with jpa and thus there is no hibernate config but a persistence.xml. I need to access the hibernate meta data to get to the PersistentClass.

So far I've found this information telling me to implement a SessionFactoryBuilderFactory as a Java service. However, the implemented getSessionFactoryBuilder is never called. (Maybe it is because the bootstrapping process is different with JPA?)

I have access to HibernateEntityManagerFactory and thus SessionFactory. Is there a way to access MetadataImplementor from here? Or can I get access to the MetadataImplementor (or PersistentClasses) from the JPA EntityManager?

Community
  • 1
  • 1
Beatinu
  • 11
  • 3

1 Answers1

0

You can simply cast the MetaModel returned from your EntityManager like this:

MetamodelImplementor model = (MetamodelImplementor) em.getMetamodel();
Thomas
  • 2,231
  • 1
  • 19
  • 27