Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- EntityManagerFactory emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT);
- SessionFactoryImpl sessionFactory = null;
- try {
- Persistence.generateSchema(PERSISTENCE_UNIT, null);
- } finally {
- sessionFactory = emf.unwrap(SessionFactoryImpl.class);
- sessionFactory.getServiceRegistry().destroy();
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <persistence version="2.1"
- xmlns="http://xmlns.jcp.org/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
- http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
- <persistence-unit name="ddl-gen">
- <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
- <class>***</class>
- <class>***</class>
- <class>***</class>
- <properties>
- <property name="javax.persistence.schema-generation.scripts.action" value="create"/>
- <property name="javax.persistence.schema-generation.scripts.create-target"
- value="${project.basedir}/src/main/resources/META-INF/sql/init.sql"/>
- <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
- <property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://***/~/***"/>
- <property name="hibernate.connection.username" value="sa"/>
- <property name="hibernate.connection.password" value=""/>
- </properties>
- </persistence-unit>
- </persistence>
- 16:11:41.062 [main] DEBUG org.hibernate.internal.SessionFactoryRegistry - Not binding SessionFactory to JNDI, no JNDI name configured
- 16:11:41.062 [main] DEBUG org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator - wasInitiallyAutoCommit=false
- 16:11:41.062 [main] INFO org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
- 16:11:41.066 [main] DEBUG org.hibernate.service.internal.AbstractServiceRegistryImpl - Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries
- 16:11:41.066 [main] INFO org.hibernate.orm.connections - HHH10001008: Cleaning up connection pool [jdbc:h2:tcp://***/~/***]
- 16:11:41.067 [main] DEBUG org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl - Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries
- 16:12:10.932 [pool-2-thread-1] DEBUG org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl - Connection pool now considered primed; min-size will be maintained
- public static void main(String[] args) {
- Persistence.generateSchema(PERSISTENCE_UNIT, null);
- }
- 16:07:26.890 [main] DEBUG org.hibernate.internal.SessionFactoryRegistry - Not binding SessionFactory to JNDI, no JNDI name configured
- 16:07:26.895 [main] DEBUG org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator - wasInitiallyAutoCommit=false
- 16:07:26.896 [main] INFO org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
- 16:07:54.274 [pool-1-thread-1] DEBUG org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl - Connection pool now considered primed; min-size will be maintained
Add Comment
Please, Sign In to add comment