I can get the JPA Config like this:
Configuration jpaConf = Configuration.root().getConfig("jpa");
But how can I get the org.hibernate.cfg.Configuration which I need to do a Schema Export like in this Question (base on Play Framework 1): Using SchemaExport in Play Framework
My Play Framework 2.x application.conf has this:
# Database configuration
# ~~~~~
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/dpma"
db.default.user=bp
db.default.jndiName=DefaultDS
jpa.default=defaultPersistenceUnit
my persistence.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL9Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true"/>
<!--<property name="hibernate.default_schema" value=""legalEntitiesTest""/>-->
<property name="hibernate.globally_quoted_identifiers" value="false"/>
</properties>
</persistence-unit>
</persistence>
**For those unfamiliar with Play Framework: ** https://playframework.com/documentation/2.2.4/JavaJPA
You can create hibernate configuration object yourself, using hibernate configuration file:
If you do not use hibernate cfg file, you can instead add JPA entities to configuration this way (it assums all your JPA classes belong to one package):
Before you execute schema export, remember to set dialect: