On Play Framework 1.2.5 with Jpa+Hibernate as ORM, I would like to call programmatically Hibernate tool SchemaExport. I tried this code:
Ejb3Configuration cfg = getPlayEjb3Configuration();
Configuration configuration = cfg.getHibernateConfiguration();
try {
SchemaExport se = new SchemaExport(configuration);
se.setHaltOnError(true);
se.setDelimiter(";").setFormat(true);
se.execute(true, false, false, false);
}
catch(Exception e) {
…
}
Where getPlayEjb3Configuration()
is a "copy" of play framework JPAPlugin.onApplicationStart()
.
I always obtain a 'no datasource provided'
exception message.
I try to preserve configuration in a static reference (modifying play framework) without difference.
How can I obtain from play framework a correct Ejb3Configuration/HibernateConfiguration? There's any alternative way to call SchemaExport?
I found a solution on creating SchemaExport:
And everything works.