Skip to content

Commit

Permalink
HHH-18003 - Create a PersistenceUnitDescriptor wrapper around JPA 3.2…
Browse files Browse the repository at this point in the history
… PersistenceConfiguration
  • Loading branch information
sebersole committed Apr 24, 2024
1 parent c12fc27 commit 8674c5b
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.test.jpa.boot;

import org.hibernate.cfg.SchemaToolingSettings;
import org.hibernate.jpa.HibernatePersistenceProvider;
import org.hibernate.tool.schema.Action;

import org.hibernate.testing.orm.domain.StandardDomainModel;
import org.junit.jupiter.api.Test;

import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.PersistenceConfiguration;

/**
* @author Steve Ebersole
*/
public class PersistenceConfigurationTests {
@Test
void test1() {
final PersistenceConfiguration configuration = new PersistenceConfiguration( "tst1" )
.property( SchemaToolingSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.CREATE );
for ( Class<?> annotatedClass : StandardDomainModel.RETAIL.getDescriptor().getAnnotatedClasses() ) {
configuration.managedClass( annotatedClass );
}
try (EntityManagerFactory entityManagerFactory = new HibernatePersistenceProvider().createEntityManagerFactory( configuration )) {
entityManagerFactory.runInTransaction( entityManager -> {
entityManager.createQuery( "from Order" ).getResultList();
} );
}
}
}

0 comments on commit 8674c5b

Please sign in to comment.