Code Monkey home page Code Monkey logo

hibernate-test-case-templates's Introduction

Hibernate Test Case Templates

When creating a bug report for any project within the Hibernate family, it's extremely helpful (and, frankly, required) to have an adequate test case available. This is obviously important to make reproducing the issue as easy as possible. But it's also vital longer-term. Nearly every bug fix should include a regression test, which frequently is based on the original reproducer (sometimes, it's the reproducer, verbatim).

To help create useful test cases, we're opening up this repo with various templates. Please see the READMEs in each project's subdir for more info.

As always, this is open source for a reason! If these templates can be improved in any way, please let us know (either through our JIRA instance or through GitHub Issues). Better yet, send us a pull request!

hibernate-test-case-templates's People

Contributors

ahus1 avatar bartoszmiller avatar beikov avatar brmeyer avatar dependabot[bot] avatar gbadner avatar gsmet avatar gunnarmorling avatar marko-bekhta avatar mbladel avatar mkomko avatar naros avatar sanne avatar vladmihalcea avatar yrodiere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hibernate-test-case-templates's Issues

Hi all i got error when using hibernate 5.4.2.Final

i am using eclipse neo when i want build my java application i got error
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named FastMatch

here my persistence.xml

<?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="FastMatch" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <class>com.dxtr.hibernate.newOrderSingleEntity</class>
        <properties>
            <property name="eclipselink.logging.level" value="INFO"/>
             <property name="eclipselink.logging.level.sql" value="FINE"/>
            <property name="eclipselink.logging.parameters" value="true"/> 
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://url/tables" />
            <property name="javax.persistence.jdbc.user" value="username" />
            <property name="javax.persistence.jdbc.password" value="password" />
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
            <property name="eclipselink.logging.level.connection" value="FINEST"/>
        </properties>
    </persistence-unit>
</persistence>

i have add org.hibernate.jpa.HibernatePersistenceProvider

and this is my pom.xml

<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-core</artifactId>
   <version>5.4.2.Final</version>
 </dependency>
   <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-entitymanager</artifactId>
   <version>5.4.2.Final</version>
 </dependency>
  <dependency>
     <groupId>org.hibernate.javax.persistence</groupId>
     <artifactId>hibernate-jpa-2.1-api</artifactId>
     <version>1.0.0.Final</version>
 </dependency>
 <dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
 <groupId>mysql</groupId>
 <artifactId>mysql-connector-java</artifactId>
 <version>5.1.48</version>
</dependency>

how to solve my problem ? i have try using other solution in google but i cannot solve this problem
regards,

Fuad

The hibernate-orm-5 module does not build with Hibernate 5.5.x or 5.6.x

When updating the Hibernate version in the Maven module hibernate-orm-5 to any version of 5.5.x or 5.6.x, the ORMStandaloneTestCase fails with a NullPointerException. There is a breaking change between 5.4.x and 5.5.x, it looks like that starting with 5.5.x the connection properties must be configured in hibernate.properties.

Running org.hibernate.bugs.JPAUnitTestCase
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.195 sec
Running org.hibernate.bugs.ORMUnitTestCase
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.02 sec <<< FAILURE!
org.hibernate.bugs.ORMUnitTestCase  Time elapsed: 0.019 sec  <<< ERROR!
java.lang.ExceptionInInitializerError
	at org.hibernate.testing.cleaner.DatabaseCleanerContext.<clinit>(DatabaseCleanerContext.java:17)
	at org.hibernate.testing.cleaner.DatabaseCleaner.clearSchemas(DatabaseCleaner.java:17)
	at org.hibernate.testing.junit4.BaseUnitTestCase.<clinit>(BaseUnitTestCase.java:39)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:250)
	at org.hibernate.testing.junit4.CustomRunner.getTestInstance(CustomRunner.java:139)
	at org.hibernate.testing.junit4.BeforeClassCallbackHandler.evaluate(BeforeClassCallbackHandler.java:25)
	at org.hibernate.testing.junit4.AfterClassCallbackHandler.evaluate(AfterClassCallbackHandler.java:25)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.IllegalArgumentException: java.lang.NullPointerException
	at org.hibernate.testing.cleaner.JdbcConnectionContext.<clinit>(JdbcConnectionContext.java:46)
	... 25 more
Caused by: java.lang.NullPointerException
	at java.base/java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
	at java.base/java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006)
	at java.base/java.util.Properties.put(Properties.java:1337)
	at org.hibernate.testing.cleaner.JdbcConnectionContext.<clinit>(JdbcConnectionContext.java:42)
	... 25 more

The test case can will succeed if you add hibernate.connection.password to hibernate.properties (No value for the property or any value)

Add templates that works with the JPA EntityManager too

We need to support both the Hibernate-specific API and Java Persistence API as well. This way, each issue can be represented exactly how the reporter has bumped into it.

In the test cases that I run for my book, I already have this functionality:

https://github.com/vladmihalcea/high-performance-java-persistence/blob/master/core/src/test/java/com/vladmihalcea/book/hpjp/util/AbstractTest.java

Although I combined both in one base class, which I then extend for each use case, we can have separate templates for Hibernate and JPA.

Cascade Behaviour Different between Hibernate and JPA bootstrapped app with same cascade annotations

Cascade Behaviour Different between Hibernate and JPA bootstrapped app with same cascade annotations

Under JPA we get the unsaved transient object exception

Hibernate bootstrap is ok

The two entities have mappings to a common entity, one is the owner and hence has cascade=all, but we get the issue that this cascade is not being found and hence it thinks the second entity is referencing a transient object.

Version.java throws ArrayIndexOutOfBoundsException

I am using hibernate validator 5.2.2, and executing with Open JDK 11, on Windows 10.

This is code snippet from org.hibernate.validator.internal.util.Version.java

public static int getJavaRelease() {
	// Will return something like 1.8
	String[] specificationVersion = System.getProperty( "java.specification.version" ).split( "\\." );

	return Integer.parseInt( specificationVersion[1] );
}

Integer.parseInt( specificationVersion[1] ) => this line assumes the java.specification.version system property will always have two or more parts. But OpenJDK 11, on Windows10, returning just "11".

Because of this, this class throwing ArrayIndexOutOfBoundsException

JDBC context is initialized while writing schema only with SchemaCreator

I'm trying to write SQL create schema file with SchemaCreator (hibernate 5.6.5.Final). I assumed I wouldn't need a database connection, because it is only writing a sql file based on my classes. When I run this code I observe a lot of warnings "No suitable driver" and "Connections could not be acquired from the underlying database".

When I look into the code I see that the SchemaCreator does have a boolean needsJdbcConnection, only this boolean is never used and a jdbc connection is always setup. This seems like a bug to me.

`
Configuration config = new Configuration();

for (Class<?> type : types) {
config.addAnnotatedClass(type);
}

ServiceRegistry serviceRegistry = config.getStandardServiceRegistryBuilder()
.applySetting(Environment.DIALECT, MmMySqlDialect.class)
.build();
MetadataSources metadataSources = new MetadataSources(serviceRegistry);
Metadata metadata = metadataSources.getMetadataBuilder().build();

SchemaExport schemaExport = new SchemaExport();
schemaExport.setHaltOnError(true);
schemaExport.setFormat(true);
schemaExport.setDelimiter(";");
try {
var tempFile = File.createTempFile("db-create", ".sql");
schemaExport.setOutputFile(tempFile.getAbsolutePath());
schemaExport.createOnly(EnumSet.of(TargetType.SCRIPT), metadata);
catch (IOException e) {
system.out.println(e);
}`

hibernate-orm-6 runs no tests for 6.6.0.Final

I am trying to create a test case for a bug I am experiencing in Hibernate 6.6.0; however, mvn test under hibernate-orm-6 does not execute any tests:

hibernate-orm-6 % mvn test
[INFO] Scanning for projects...
[INFO] 
[INFO] --< org.hibernate.testcasetemplate:test-case-template-hibernate-orm-6 >--
[INFO] Building Hibernate ORM 6 Test Case Template 1.0.0.Final
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ test-case-template-hibernate-orm-6 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/muller/git/hibernate-test-case-templates/orm/hibernate-orm-6/src/main/resources
[INFO] 
[INFO] --- compiler:3.13.0:compile (default-compile) @ test-case-template-hibernate-orm-6 ---
[INFO] No sources to compile
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ test-case-template-hibernate-orm-6 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources from src/test/resources to target/test-classes
[INFO] 
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ test-case-template-hibernate-orm-6 ---
[INFO] Nothing to compile - all classes are up to date.
[INFO] 
[INFO] --- hibernate-enhance:6.6.0.Final:enhance (default) @ test-case-template-hibernate-orm-6 ---
[WARNING] Skipping Hibernate bytecode enhancement plugin execution since no feature is enabled
[INFO] 
[INFO] --- surefire:3.2.2:test (default-test) @ test-case-template-hibernate-orm-6 ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.797 s
[INFO] Finished at: 2024-08-12T17:46:32+02:00
[INFO] ------------------------------------------------------------------------

I created a fresh copy of the templates with no files changed. When I set the version.org.hibernate.orm back to 6.5.2.Final in pom.xml, there are four tests (those hhh123Test) executed:

% mvn test
[INFO] Scanning for projects...
[INFO] 
[INFO] --< org.hibernate.testcasetemplate:test-case-template-hibernate-orm-6 >--
[INFO] Building Hibernate ORM 6 Test Case Template 1.0.0.Final
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ test-case-template-hibernate-orm-6 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/muller/git/hibernate-test-case-templates/orm/hibernate-orm-6/src/main/resources
[INFO] 
[INFO] --- compiler:3.13.0:compile (default-compile) @ test-case-template-hibernate-orm-6 ---
[INFO] No sources to compile
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ test-case-template-hibernate-orm-6 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources from src/test/resources to target/test-classes
[INFO] 
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ test-case-template-hibernate-orm-6 ---
[INFO] Nothing to compile - all classes are up to date.
[INFO] 
[INFO] --- hibernate-enhance:6.5.2.Final:enhance (default) @ test-case-template-hibernate-orm-6 ---
[WARNING] Skipping Hibernate bytecode enhancement plugin execution since no feature is enabled
[INFO] 
[INFO] --- surefire:3.2.2:test (default-test) @ test-case-template-hibernate-orm-6 ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
2024-08-12 17:50:23 INFO  Version:44 - HHH000412: Hibernate ORM core version 6.5.2.Final
2024-08-12 17:50:23 INFO  Environment:148 - HHH000205: Loaded properties from resource hibernate.properties: {hibernate.format_sql=true, jakarta.persistence.validation.mode=NONE, hibernate.dialect=org.hibernate.dialect.H2Dialect, hibernate.connection.username=sa, hibernate.connection.url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1, hibernate.max_fetch_depth=5, hibernate.show_sql=false, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.driver_class=org.h2.Driver, hibernate.connection.password=****, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.pool_size=5, hibernate.cache.region.factory_class=org.hibernate.testing.cache.CachingRegionFactory, hibernate.service.allow_crawling=false, hibernate.session.events.log=true}
[INFO] Running org.hibernate.bugs.JPAUnitTestCase
2024-08-12 17:50:24 INFO  LogHelper:31 - HHH000204: Processing PersistenceUnitInfo [name: templatePU]
2024-08-12 17:50:24 WARN  CachingRegionFactory:48 - org.hibernate.testing.cache.CachingRegionFactory should be only used for testing.
2024-08-12 17:50:24 INFO  RegionFactoryInitiator:53 - HHH000025: Second-level cache region factory [org.hibernate.testing.cache.CachingRegionFactory]
2024-08-12 17:50:24 WARN  pooling:81 - HHH10001002: Using built-in connection pool (not intended for production use)
2024-08-12 17:50:24 INFO  pooling:136 - HHH10001005: Loaded JDBC driver class: org.h2.Driver
2024-08-12 17:50:24 INFO  pooling:158 - HHH10001012: Connecting with JDBC URL [jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1]
2024-08-12 17:50:24 INFO  pooling:167 - HHH10001001: Connection properties: {password=****, user=sa}
2024-08-12 17:50:24 INFO  pooling:171 - HHH10001003: Autocommit mode: false
2024-08-12 17:50:24 INFO  pooling:372 - HHH10001115: Connection pool size: 5 (min=1)
2024-08-12 17:50:24 WARN  deprecation:153 - HHH90000025: H2Dialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-12 17:50:24 INFO  JtaPlatformInitiator:56 - HHH000490: Using JTA platform [org.hibernate.engine.transaction.jta.platform.internal.WildFlyStandAloneJtaPlatform]
2024-08-12 17:50:24 INFO  StatisticalLoggingSessionEventListener:280 - Session Metrics {
    27416 nanoseconds spent acquiring 1 JDBC connections;
    41917 nanoseconds spent releasing 1 JDBC connections;
    0 nanoseconds spent preparing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC batches;
    0 nanoseconds spent performing 0 L2C puts;
    0 nanoseconds spent performing 0 L2C hits;
    0 nanoseconds spent performing 0 L2C misses;
    0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
    0 nanoseconds spent executing 0 pre-partial-flushes;
    0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
2024-08-12 17:50:24 INFO  pooling:607 - HHH10001008: Cleaning up connection pool [jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.357 s -- in org.hibernate.bugs.JPAUnitTestCase
[INFO] Running org.hibernate.bugs.ORMUnitTestCase
2024-08-12 17:50:24 INFO  CustomRunner:126 - BeforeClass: org.hibernate.bugs.ORMUnitTestCase
2024-08-12 17:50:24 WARN  CachingRegionFactory:48 - org.hibernate.testing.cache.CachingRegionFactory should be only used for testing.
2024-08-12 17:50:24 INFO  RegionFactoryInitiator:53 - HHH000025: Second-level cache region factory [org.hibernate.testing.cache.CachingRegionFactory]
2024-08-12 17:50:24 WARN  pooling:81 - HHH10001002: Using built-in connection pool (not intended for production use)
2024-08-12 17:50:24 INFO  pooling:136 - HHH10001005: Loaded JDBC driver class: org.h2.Driver
2024-08-12 17:50:24 INFO  pooling:158 - HHH10001012: Connecting with JDBC URL [jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1]
2024-08-12 17:50:24 INFO  pooling:167 - HHH10001001: Connection properties: {password=****, user=sa}
2024-08-12 17:50:24 INFO  pooling:171 - HHH10001003: Autocommit mode: false
2024-08-12 17:50:24 INFO  pooling:372 - HHH10001115: Connection pool size: 5 (min=1)
2024-08-12 17:50:24 WARN  deprecation:153 - HHH90000025: H2Dialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-12 17:50:24 INFO  JtaPlatformInitiator:56 - HHH000490: Using JTA platform [org.hibernate.engine.transaction.jta.platform.internal.WildFlyStandAloneJtaPlatform]
2024-08-12 17:50:24 INFO  CustomRunner:133 - Test: hhh123Test
2024-08-12 17:50:24 INFO  StatisticalLoggingSessionEventListener:280 - Session Metrics {
    0 nanoseconds spent acquiring 0 JDBC connections;
    0 nanoseconds spent releasing 0 JDBC connections;
    0 nanoseconds spent preparing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC batches;
    0 nanoseconds spent performing 0 L2C puts;
    0 nanoseconds spent performing 0 L2C hits;
    0 nanoseconds spent performing 0 L2C misses;
    0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
    0 nanoseconds spent executing 0 pre-partial-flushes;
    0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.050 s -- in org.hibernate.bugs.ORMUnitTestCase
[INFO] Running org.hibernate.bugs.QuarkusLikeORMUnitTestCase
2024-08-12 17:50:24 INFO  CustomRunner:126 - BeforeClass: org.hibernate.bugs.QuarkusLikeORMUnitTestCase
2024-08-12 17:50:24 WARN  CachingRegionFactory:48 - org.hibernate.testing.cache.CachingRegionFactory should be only used for testing.
2024-08-12 17:50:24 INFO  RegionFactoryInitiator:53 - HHH000025: Second-level cache region factory [org.hibernate.testing.cache.CachingRegionFactory]
2024-08-12 17:50:24 WARN  deprecation:153 - HHH90000025: H2Dialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-12 17:50:24 INFO  JtaPlatformInitiator:56 - HHH000490: Using JTA platform [org.hibernate.engine.transaction.jta.platform.internal.WildFlyStandAloneJtaPlatform]
[INFO] Running org.hibernate.bugs.QuarkusLikeORMUnitTestCase
2024-08-12 17:50:24 INFO  CustomRunner:133 - Test: hhh123Test
2024-08-12 17:50:24 INFO  StatisticalLoggingSessionEventListener:280 - Session Metrics {
    0 nanoseconds spent acquiring 0 JDBC connections;
    0 nanoseconds spent releasing 0 JDBC connections;
    0 nanoseconds spent preparing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC batches;
    0 nanoseconds spent performing 0 L2C puts;
    0 nanoseconds spent performing 0 L2C hits;
    0 nanoseconds spent performing 0 L2C misses;
    0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
    0 nanoseconds spent executing 0 pre-partial-flushes;
    0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s -- in org.hibernate.bugs.QuarkusLikeORMUnitTestCase
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.018 s -- in org.hibernate.bugs.QuarkusLikeORMUnitTestCase
[INFO] Running org.hibernate.bugs.ORMStandaloneTestCase
2024-08-12 17:50:24 WARN  CachingRegionFactory:48 - org.hibernate.testing.cache.CachingRegionFactory should be only used for testing.
2024-08-12 17:50:24 INFO  RegionFactoryInitiator:53 - HHH000025: Second-level cache region factory [org.hibernate.testing.cache.CachingRegionFactory]
2024-08-12 17:50:24 WARN  pooling:81 - HHH10001002: Using built-in connection pool (not intended for production use)
2024-08-12 17:50:24 INFO  pooling:136 - HHH10001005: Loaded JDBC driver class: org.h2.Driver
2024-08-12 17:50:24 INFO  pooling:158 - HHH10001012: Connecting with JDBC URL [jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1]
2024-08-12 17:50:24 INFO  pooling:167 - HHH10001001: Connection properties: {password=****, user=sa}
2024-08-12 17:50:24 INFO  pooling:171 - HHH10001003: Autocommit mode: false
2024-08-12 17:50:24 INFO  pooling:372 - HHH10001115: Connection pool size: 5 (min=1)
2024-08-12 17:50:24 WARN  deprecation:153 - HHH90000025: H2Dialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-12 17:50:24 INFO  JtaPlatformInitiator:56 - HHH000490: Using JTA platform [org.hibernate.engine.transaction.jta.platform.internal.WildFlyStandAloneJtaPlatform]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 s -- in org.hibernate.bugs.ORMStandaloneTestCase
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.759 s
[INFO] Finished at: 2024-08-12T17:50:24+02:00
[INFO] ------------------------------------------------------------------------

The only difference is the setting of version.org.hibernate.orm in pom.xml. I can see the four test templates are also executed with version 6.6.0.Alpha1, but not with any later version.

Auto-Detect Entities

Although the test case suggests that the project will automatically pick up new JPA entities, I had to add <class> nodes to the persistence.xml to have them picked up. I haven't used bare Hibernate (without Spring Boot) with JPA, so maybe I'm missing something about how this is supposed to work, but I cloned the project, added a src/main/java, and put my entities under there, and got this error:

Once I added the <class> nodes, everything was fine. Did I miss something?

java.lang.IllegalArgumentException: Unknown entity: org.hibernate.bugs.Application
	at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:807)
	at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:788)
	at org.hibernate.bugs.JPAUnitTestCase.hhh123Test(JPAUnitTestCase.java:39)

No Persistence provider for EntityManager named templatePU

In order to debug an issue we are facing with Hibernate version 5.0.11.Final, I've downgraded the hibernate version in the test-case-template-hibernate-orm5 POM as:

<version.org.hibernate>5.0.11.Final</version.org.hibernate>

But that gives the below error when running the added test.

javax.persistence.PersistenceException: No Persistence provider for EntityManager named templatePU

	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
	at org.hibernate.bugs.JPAUnitTestCase.init(JPAUnitTestCase.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at com.intellij.junit4.JUnit4TestRunnerUtil$IgnoreIgnoredTestJUnit4ClassRunner.runChild(JUnit4TestRunnerUtil.java:363)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

The tests and the template works perfectly fine with the provided version 5.2.2.Final but fails with any version used from 5.0.x

Any help on this please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.