How do I get the Hibernate Configuration after the EntityManagerFactory has been built?
My web framework (Play 1.2.5) creates an EJB3Configuration local to a method which it uses to create an EntityManagerFactory (source). I am working on a script and would like to run the generateSchemaUpdateScript() method from Configuration to make SQL scripts I can verify and run on production deploys. The problem I am having is that I cannot figure out how to access the Configuration object that was used or how to generate a Configuration object after the EntityManagerFactory has been built.
You cannot get the configuration object back from the entitymanagerfactory because hibernate implementation EntityManagerFactoryImpl does not hold a reference to the configuration object
Your choices are
- duplicates the code from JPAPlugin in your script to create your own configuration object
- configure hibernate tools to work on your classes. I never used this tool myself but I guess that properly configured he can generate the ddl for you
- generates back the ddl script from your database