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.

Answers


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

Need Your Help

Duck typing: how to avoid name collisions?

python language-agnostic duck-typing dynamic-typing

I think understand the idea of duck typing, and would like to use it more often in my code. However, I am concerned about one potential problem: name collision.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.