finalQuery = criteriaQuery.multiselect(root.get("commonName"),
+ percentageOutSelection);
+ return entityManager.createQuery(finalQuery).getResultList();
+ }
+}
diff --git a/orm/hibernate-orm-6/src/main/java/org/spring/data/jpa/bugs/OurStatus.java b/orm/hibernate-orm-6/src/main/java/org/spring/data/jpa/bugs/OurStatus.java
new file mode 100644
index 00000000..790c2dd4
--- /dev/null
+++ b/orm/hibernate-orm-6/src/main/java/org/spring/data/jpa/bugs/OurStatus.java
@@ -0,0 +1,7 @@
+package org.spring.data.jpa.bugs;
+
+public enum OurStatus {
+ STATUS_1,
+ STATUS_2,
+ ;
+}
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java
deleted file mode 100644
index 3734df49..00000000
--- a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.hibernate.bugs;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import jakarta.persistence.EntityManager;
-import jakarta.persistence.EntityManagerFactory;
-import jakarta.persistence.Persistence;
-
-/**
- * This template demonstrates how to develop a test case for Hibernate ORM, using the Java Persistence API.
- */
-class JPAUnitTestCase {
-
- private EntityManagerFactory entityManagerFactory;
-
- @BeforeEach
- void init() {
- entityManagerFactory = Persistence.createEntityManagerFactory( "templatePU" );
- }
-
- @AfterEach
- void destroy() {
- entityManagerFactory.close();
- }
-
- // Entities are auto-discovered, so just add them anywhere on class-path
- // Add your tests, using standard JUnit.
- @Test
- void hhh123Test() throws Exception {
- EntityManager entityManager = entityManagerFactory.createEntityManager();
- entityManager.getTransaction().begin();
- // Do stuff...
- entityManager.getTransaction().commit();
- entityManager.close();
- }
-}
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMStandaloneTestCase.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMStandaloneTestCase.java
deleted file mode 100644
index 7b7615ed..00000000
--- a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMStandaloneTestCase.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.hibernate.bugs;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.boot.Metadata;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * This template demonstrates how to develop a standalone test case for Hibernate ORM. Although this is perfectly
- * acceptable as a reproducer, usage of ORMUnitTestCase is preferred!
- */
-class ORMStandaloneTestCase {
-
- private SessionFactory sf;
-
- @BeforeEach
- void setup() {
- StandardServiceRegistryBuilder srb = new StandardServiceRegistryBuilder()
- // Add in any settings that are specific to your test. See resources/hibernate.properties for the defaults.
- .applySetting( "hibernate.show_sql", "true" )
- .applySetting( "hibernate.format_sql", "true" )
- .applySetting( "hibernate.hbm2ddl.auto", "update" );
-
- Metadata metadata = new MetadataSources( srb.build() )
- // Add your entities here.
- // .addAnnotatedClass( Foo.class )
- .buildMetadata();
-
- sf = metadata.buildSessionFactory();
- }
-
- // Add your tests, using standard JUnit 5:
- @Test
- void hhh123Test() throws Exception {
-
- }
-}
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMUnitTestCase.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMUnitTestCase.java
deleted file mode 100644
index eefb7df4..00000000
--- a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMUnitTestCase.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2014 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.hibernate.bugs;
-
-import org.hibernate.cfg.AvailableSettings;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-/**
- * This template demonstrates how to develop a test case for Hibernate ORM, using its built-in unit test framework.
- * Although ORMStandaloneTestCase is perfectly acceptable as a reproducer, usage of this class is much preferred.
- * Since we nearly always include a regression test with bug fixes, providing your reproducer using this method
- * simplifies the process.
- *
- * What's even better? Fork hibernate-orm itself, add your test case directly to a module's unit tests, then
- * submit it as a PR!
- */
-@DomainModel(
- annotatedClasses = {
- // Add your entities here.
- // Foo.class,
- // Bar.class
- },
- // If you use *.hbm.xml mappings, instead of annotations, add the mappings here.
- xmlMappings = {
- // "org/hibernate/test/Foo.hbm.xml",
- // "org/hibernate/test/Bar.hbm.xml"
- }
-)
-@ServiceRegistry(
- // Add in any settings that are specific to your test. See resources/hibernate.properties for the defaults.
- settings = {
- // For your own convenience to see generated queries:
- @Setting(name = AvailableSettings.SHOW_SQL, value = "true"),
- @Setting(name = AvailableSettings.FORMAT_SQL, value = "true"),
- // @Setting( name = AvailableSettings.GENERATE_STATISTICS, value = "true" ),
-
- // Add your own settings that are a part of your quarkus configuration:
- // @Setting( name = AvailableSettings.SOME_CONFIGURATION_PROPERTY, value = "SOME_VALUE" ),
- }
-)
-@SessionFactory
-class ORMUnitTestCase {
-
- // Add your tests, using standard JUnit 5.
- @Test
- void hhh123Test(SessionFactoryScope scope) throws Exception {
- scope.inTransaction( session -> {
- // Do stuff...
- } );
- }
-}
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeEnhancementContext.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeEnhancementContext.java
deleted file mode 100644
index 9d9e2d6e..00000000
--- a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeEnhancementContext.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.hibernate.bugs;
-
-import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext;
-import org.hibernate.bytecode.enhance.spi.UnloadedField;
-import org.hibernate.bytecode.enhance.spi.UnsupportedEnhancementStrategy;
-
-public class QuarkusLikeEnhancementContext extends DefaultEnhancementContext {
- @Override
- public boolean doBiDirectionalAssociationManagement(final UnloadedField field) {
- //Don't enable automatic association management as it's often too surprising.
- //Also, there's several cases in which its semantics are of unspecified,
- //such as what should happen when dealing with ordered collections.
- return false;
- }
-
- @Override
- public UnsupportedEnhancementStrategy getUnsupportedEnhancementStrategy() {
- // We expect model classes to be enhanced.
- // Lack of enhancement could lead to many problems,
- // from bad performance, to Quarkus-specific optimizations causing errors/data loss,
- // to incorrect generated bytecode (references to non-existing methods).
- // If something prevents enhancement, it's just safer to have Hibernate ORM's enhancer fail
- // with a clear error message pointing to the application class that needs to be fixed.
- return UnsupportedEnhancementStrategy.FAIL;
- }
-}
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java
deleted file mode 100644
index 77c6a7af..00000000
--- a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2014 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.hibernate.bugs;
-
-import org.hibernate.cfg.AvailableSettings;
-
-import org.hibernate.testing.bytecode.enhancement.CustomEnhancementContext;
-import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-/**
- * This template demonstrates how to develop a test case for Hibernate ORM, using its built-in unit test framework.
- *
- * What's even better? Fork hibernate-orm itself, add your test case directly to a module's unit tests, then
- * submit it as a PR!
- */
-@DomainModel(
- annotatedClasses = {
- // Add your entities here, e.g.:
- // Foo.class,
- // Bar.class
- }
-)
-@ServiceRegistry(
- // Add in any settings that are specific to your test. See resources/hibernate.properties for the defaults.
- settings = {
- // For your own convenience to see generated queries:
- @Setting(name = AvailableSettings.SHOW_SQL, value = "true"),
- @Setting(name = AvailableSettings.FORMAT_SQL, value = "true"),
- // @Setting( name = AvailableSettings.GENERATE_STATISTICS, value = "true" ),
-
- // Other settings that will make your test case run under similar configuration that Quarkus is using by default:
- @Setting(name = AvailableSettings.PREFERRED_POOLED_OPTIMIZER, value = "pooled-lo"),
- @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "16"),
- @Setting(name = AvailableSettings.BATCH_FETCH_STYLE, value = "PADDED"),
- @Setting(name = AvailableSettings.QUERY_PLAN_CACHE_MAX_SIZE, value = "2048"),
- @Setting(name = AvailableSettings.DEFAULT_NULL_ORDERING, value = "none"),
- @Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true"),
- @Setting(name = AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY, value = "none"),
- @Setting(name = AvailableSettings.ORDER_UPDATES, value = "true"),
-
- // Add your own settings that are a part of your quarkus configuration:
- // @Setting( name = AvailableSettings.SOME_CONFIGURATION_PROPERTY, value = "SOME_VALUE" ),
- }
-)
-@SessionFactory
-@BytecodeEnhanced
-@CustomEnhancementContext(QuarkusLikeEnhancementContext.class)
-class QuarkusLikeORMUnitTestCase {
-
- // Add your tests, using standard JUnit.
- @Test
- void hhh123Test(SessionFactoryScope scope) throws Exception {
- scope.inTransaction( session -> {
- // Do stuff...
- } );
- }
-}
diff --git a/orm/hibernate-orm-6/src/test/java/org/spring/data/jpa/bugs/OurServiceTest.java b/orm/hibernate-orm-6/src/test/java/org/spring/data/jpa/bugs/OurServiceTest.java
new file mode 100644
index 00000000..1160446c
--- /dev/null
+++ b/orm/hibernate-orm-6/src/test/java/org/spring/data/jpa/bugs/OurServiceTest.java
@@ -0,0 +1,38 @@
+package org.spring.data.jpa.bugs;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.context.annotation.Import;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.TestPropertySource;
+
+@SpringBootTest
+@TestPropertySource(locations = "classpath:application-test.yml")
+@ActiveProfiles("test")
+@Import({ OurServiceTest.TestConfiguration.class })
+class OurServiceTest {
+
+ @Autowired
+ private OurService ourService;
+
+ // Add your tests, using standard JUnit 5.
+ @Test
+ void test() {
+ List result = ourService.createPercentageQuery();
+ assertTrue(result.isEmpty());
+ }
+
+ @ComponentScan(basePackages = "org.spring.data.jpa.bugs",
+ excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = {
+ ".*TestConfiguration"
+ }))
+ @SpringBootApplication
+ static class TestConfiguration {}
+}
diff --git a/orm/hibernate-orm-6/src/test/resources/META-INF/persistence.xml b/orm/hibernate-orm-6/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index 3c18b748..00000000
--- a/orm/hibernate-orm-6/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- Hibernate test case template Persistence Unit
- org.hibernate.jpa.HibernatePersistenceProvider
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/orm/hibernate-orm-6/src/test/resources/application-test.yml b/orm/hibernate-orm-6/src/test/resources/application-test.yml
new file mode 100644
index 00000000..b8d20db0
--- /dev/null
+++ b/orm/hibernate-orm-6/src/test/resources/application-test.yml
@@ -0,0 +1,23 @@
+spring:
+ datasource:
+ url: jdbc:h2:mem:tests;DB_CLOSE_DELAY=-1;MODE=PostgreSQL;DB_CLOSE_ON_EXIT=FALSE
+ username: sa
+ password:
+ hikari:
+ poolName: HikariPool-default
+ driver-class-name: org.h2.Driver
+ jpa:
+ properties:
+ hibernate:
+ show_sql: true
+ format_sql: true
+ jakarta.persistence.schema-generation.database.action: drop-and-create
+ generate-ddl: true
+ hibernate:
+ # ignored due to two connection pools, replaced by spring.jpa.properties.jakarta.persistence.schema-generation.database.action
+ # ddl-auto: create-drop
+ database-platform: org.hibernate.dialect.PostgreSQLDialect
+
+ main:
+ allow-bean-definition-overriding: true
+
diff --git a/orm/hibernate-orm-6/src/test/resources/hibernate.properties b/orm/hibernate-orm-6/src/test/resources/hibernate.properties
deleted file mode 100644
index 9c894d7b..00000000
--- a/orm/hibernate-orm-6/src/test/resources/hibernate.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# 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 .
-#
-
-hibernate.dialect org.hibernate.dialect.H2Dialect
-hibernate.connection.driver_class org.h2.Driver
-#hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
-hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1
-hibernate.connection.username sa
-hibernate.connection.password
-
-hibernate.connection.pool_size 5
-
-hibernate.show_sql false
-hibernate.format_sql true
-
-hibernate.max_fetch_depth 5
-
-hibernate.cache.region_prefix hibernate.test
-hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
-
-# NOTE: hibernate.jdbc.batch_versioned_data should be set to false when testing with Oracle
-hibernate.jdbc.batch_versioned_data true
-
-jakarta.persistence.validation.mode=NONE
-hibernate.service.allow_crawling=false
-hibernate.session.events.log=true
\ No newline at end of file
diff --git a/orm/hibernate-orm-6/src/test/resources/log4j2.properties b/orm/hibernate-orm-6/src/test/resources/log4j2.properties
deleted file mode 100644
index c55a2b0c..00000000
--- a/orm/hibernate-orm-6/src/test/resources/log4j2.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# Set to debug or trace if log4j initialization is failing
-status = warn
-
-# Console appender configuration
-appender.console.type = Console
-appender.console.name = consoleLogger
-appender.console.layout.type = PatternLayout
-appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-
-# Root logger level
-rootLogger.level = info
-
-# Root logger referring to console appender
-rootLogger.appenderRef.stdout.ref = consoleLogger
\ No newline at end of file