Skip to content

Commit

Permalink
Merge pull request #31454 from Sanne/HibernateReactive2
Browse files Browse the repository at this point in the history
Hibernate Reactive 2.0.0.Alpha2 & re-enabling all HR modules
  • Loading branch information
Sanne authored Mar 20, 2023
2 parents 4b201ef + 2f2caf4 commit 4799cd8
Show file tree
Hide file tree
Showing 41 changed files with 584 additions and 220 deletions.
8 changes: 4 additions & 4 deletions .github/native-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
{
"category": "Data5",
"timeout": 65,
"test-modules": "jpa-postgresql, jpa-postgresql-withxml, narayana-stm, narayana-jta, reactive-pg-client, hibernate-orm-tenancy/schema",
"test-modules": "jpa-postgresql, jpa-postgresql-withxml, narayana-stm, narayana-jta, reactive-pg-client, hibernate-reactive-postgresql, hibernate-orm-tenancy/schema",
"os-name": "ubuntu-latest"
},
{
"category": "Data6",
"timeout": 80,
"test-modules": "elasticsearch-rest-client, elasticsearch-rest-high-level-client, elasticsearch-java-client, hibernate-search-orm-elasticsearch, hibernate-search-orm-elasticsearch-tenancy, hibernate-search-orm-opensearch, hibernate-search-orm-elasticsearch-coordination-outbox-polling",
"test-modules": "elasticsearch-rest-client, elasticsearch-rest-high-level-client, elasticsearch-java-client, hibernate-search-orm-elasticsearch, hibernate-search-orm-elasticsearch-tenancy, hibernate-search-orm-opensearch, hibernate-search-orm-elasticsearch-coordination-outbox-polling, hibernate-reactive-panache, hibernate-reactive-panache-kotlin",
"os-name": "ubuntu-latest"
},
{
"category": "Data7",
"timeout": 65,
"test-modules": "reactive-oracle-client, reactive-mysql-client, reactive-db2-client",
"test-modules": "reactive-oracle-client, reactive-mysql-client, reactive-db2-client, hibernate-reactive-db2, hibernate-reactive-mysql",
"os-name": "ubuntu-latest"
},
{
Expand Down Expand Up @@ -81,7 +81,7 @@
{
"category": "Security3",
"timeout": 50,
"test-modules": "keycloak-authorization, smallrye-jwt-token-propagation",
"test-modules": "keycloak-authorization, smallrye-jwt-token-propagation, security-webauthn",
"os-name": "ubuntu-latest"
},
{
Expand Down
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<hibernate-orm.version>6.2.0.CR4</hibernate-orm.version> <!-- When updating, align bytebuddy.version to Hibernate needs as well (just below): -->
<bytebuddy.version>1.12.18</bytebuddy.version> <!-- Version controlled by Hibernate ORM's needs -->
<hibernate-commons-annotations.version>6.0.6.Final</hibernate-commons-annotations.version> <!-- version controlled by Hibernate ORM -->
<hibernate-reactive.version>1.1.9.Final</hibernate-reactive.version>
<hibernate-reactive.version>2.0.0.Alpha2</hibernate-reactive.version>
<hibernate-validator.version>8.0.0.Final</hibernate-validator.version>
<hibernate-search.version>6.1.7.Final</hibernate-search.version>
<narayana.version>6.0.0.Final</narayana.version>
Expand Down Expand Up @@ -5134,7 +5134,7 @@
</dependency>
<dependency>
<groupId>org.hibernate.reactive</groupId>
<artifactId>hibernate-reactive-core-jakarta</artifactId>
<artifactId>hibernate-reactive-core</artifactId>
<version>${hibernate-reactive.version}</version>
</dependency>
<dependency>
Expand Down
65 changes: 65 additions & 0 deletions devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,71 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-panache</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-panache-common</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-panache-kotlin</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-rest-data-panache</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-search-orm-coordination-outbox-polling</artifactId>
Expand Down
65 changes: 65 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,71 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-panache-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-panache-common-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-panache-kotlin-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-rest-data-panache-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-search-orm-coordination-outbox-polling-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkus.hibernate.reactive.deployment;

import java.util.List;

import io.quarkus.datasource.common.runtime.DatabaseKind;
import io.quarkus.hibernate.orm.deployment.spi.DatabaseKindDialectBuildItem;
import io.quarkus.hibernate.orm.runtime.HibernateOrmRuntimeConfig;
import io.quarkus.runtime.configuration.ConfigurationException;

/**
* This used to be the approach before 6bf38240 in the Hibernate ORM extension as well.
* Align to ORM? TBD
*/
@Deprecated
final class Dialects {

private Dialects() {
//utility
}

public static String guessDialect(String persistenceUnitName, String resolvedDbKind,
List<DatabaseKindDialectBuildItem> dbKindDialectBuildItems) {
for (DatabaseKindDialectBuildItem item : dbKindDialectBuildItems) {
if (DatabaseKind.is(resolvedDbKind, item.getDbKind())) {
return item.getDialect();
}
}

String error = "The Hibernate ORM extension could not guess the dialect from the database kind '" + resolvedDbKind
+ "'. Add an explicit '" + HibernateOrmRuntimeConfig.puPropertyKey(persistenceUnitName, "dialect")
+ "' property.";
throw new ConfigurationException(error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public final class HibernateReactiveLogFilter {
void setupLogFilters(BuildProducer<LogCleanupFilterBuildItem> filters) {
filters.produce(new LogCleanupFilterBuildItem(
"org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator", "HHH000181"));
//See https://hibernate.atlassian.net/browse/HHH-16224
filters.produce(new LogCleanupFilterBuildItem(
"org.hibernate.dialect.PostgreSQLPGObjectJdbcType", "HHH000514"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT;
import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT;
import static io.quarkus.hibernate.orm.deployment.HibernateConfigUtil.firstPresent;
import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_MODE;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_SHARED_CACHE_MODE;
import static org.hibernate.cfg.AvailableSettings.USE_DIRECT_REFERENCE_CACHE_ENTRIES;
import static org.hibernate.cfg.AvailableSettings.USE_QUERY_CACHE;
import static org.hibernate.cfg.AvailableSettings.USE_SECOND_LEVEL_CACHE;
Expand Down Expand Up @@ -47,7 +47,6 @@
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
import io.quarkus.deployment.recording.RecorderContext;
import io.quarkus.hibernate.orm.deployment.Dialects;
import io.quarkus.hibernate.orm.deployment.HibernateConfigUtil;
import io.quarkus.hibernate.orm.deployment.HibernateOrmConfig;
import io.quarkus.hibernate.orm.deployment.HibernateOrmConfigPersistenceUnit;
Expand All @@ -61,7 +60,7 @@
import io.quarkus.hibernate.orm.deployment.spi.DatabaseKindDialectBuildItem;
import io.quarkus.hibernate.orm.runtime.HibernateOrmRuntimeConfig;
import io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil;
import io.quarkus.hibernate.orm.runtime.recording.RecordedConfig
import io.quarkus.hibernate.orm.runtime.recording.RecordedConfig;
import io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider;
import io.quarkus.hibernate.reactive.runtime.HibernateReactive;
import io.quarkus.hibernate.reactive.runtime.HibernateReactiveRecorder;
Expand Down Expand Up @@ -217,6 +216,7 @@ PersistenceProviderSetUpBuildItem setUpPersistenceProviderAndWaitForVertxPool(Hi
// and we've seen in the past that features we add to handleHibernateORMWithNoPersistenceXml
// tend not to be added here.
// See https://github.com/quarkusio/quarkus/issues/28629.
//see producePersistenceUnitDescriptorFromConfig in ORM
private static ParsedPersistenceXmlDescriptor generateReactivePersistenceUnit(
HibernateOrmConfig hibernateOrmConfig, CombinedIndexBuildItem index,
HibernateOrmConfigPersistenceUnit persistenceUnitConfig,
Expand Down Expand Up @@ -379,7 +379,7 @@ private static ParsedPersistenceXmlDescriptor generateReactivePersistenceUnit(
p.putIfAbsent(USE_DIRECT_REFERENCE_CACHE_ENTRIES, Boolean.TRUE);
p.putIfAbsent(USE_SECOND_LEVEL_CACHE, Boolean.TRUE);
p.putIfAbsent(USE_QUERY_CACHE, Boolean.TRUE);
p.putIfAbsent(JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE);
p.putIfAbsent(JAKARTA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE);
Map<String, String> cacheConfigEntries = HibernateConfigUtil.getCacheConfigEntries(persistenceUnitConfig);
for (Entry<String, String> entry : cacheConfigEntries.entrySet()) {
desc.getProperties().setProperty(entry.getKey(), entry.getValue());
Expand All @@ -390,7 +390,7 @@ private static ParsedPersistenceXmlDescriptor generateReactivePersistenceUnit(
p.put(USE_DIRECT_REFERENCE_CACHE_ENTRIES, Boolean.FALSE);
p.put(USE_SECOND_LEVEL_CACHE, Boolean.FALSE);
p.put(USE_QUERY_CACHE, Boolean.FALSE);
p.put(JPA_SHARED_CACHE_MODE, SharedCacheMode.NONE);
p.put(JAKARTA_SHARED_CACHE_MODE, SharedCacheMode.NONE);
}

return desc;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.quarkus.hibernate.reactive.services;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.reactive.provider.impl.ReactiveServiceInitiators;
import org.hibernate.service.StandardServiceInitiators;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class ServiceInitiatorsTest {

private static final Map<String, String> HR_SERVICES = toServicesMap(ReactiveServiceInitiators.LIST);
private static final Map<String, String> ORM_SERVICES = toServicesMap(StandardServiceInitiators.LIST);
private static final Map<String, String> QUARKUS_HR_SERVICES = toServicesMap(ReactiveServiceInitiators.LIST);

// These services are NOT provided by the Hibernate Reactive default initiators, and that should be fine:
private static final Set<String> HR_INTENTIONALLY_OMITTED = Set
.of("org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformResolver");

@Test
public void serviceInitiatorsAreUnique() {
Assertions.assertEquals(HR_SERVICES.size(), ReactiveServiceInitiators.LIST.size());
Assertions.assertEquals(ORM_SERVICES.size(), StandardServiceInitiators.LIST.size());
Assertions.assertEquals(ORM_SERVICES.size(), StandardServiceInitiators.LIST.size());
}

private static Map<String, String> toServicesMap(List<StandardServiceInitiator<?>> list) {
TreeMap<String, String> rolesToImplMap = new TreeMap<>();
for (StandardServiceInitiator<?> initiator : list) {
final String serviceRole = initiator.getServiceInitiated().getName();
rolesToImplMap.put(serviceRole, initiator.getClass().getName());
}
return Collections.unmodifiableMap(rolesToImplMap);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testIncluded(UniAsserter asserter) {
public void testExcluded(UniAsserter asserter) {
ExcludedEntity entity = new ExcludedEntity("gsmet");
asserter.assertFailedWith(() -> persist(entity), t -> {
assertThat(t).hasMessageContaining("Unknown entity");
assertThat(t).hasMessageContaining("Unable to locate persister");
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testIncluded(UniAsserter asserter) {
public void testExcluded(UniAsserter asserter) {
ExcludedEntity entity = new ExcludedEntity("gsmet");
asserter.assertFailedWith(() -> persist(entity), t -> {
assertThat(t).hasMessageContaining("Unknown entity");
assertThat(t).hasMessageContaining("Unable to locate persister:");
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
-- tag::adocSQL[]
INSERT INTO hero(id, name, otherName, picture, powers, level)
VALUES (nextval('hibernate_sequence'), 'Chewbacca', '', 'https://www.superherodb.com/pictures2/portraits/10/050/10466.jpg', 'Agility, Longevity, Marksmanship, Natural Weapons, Stealth, Super Strength, Weapons Master', 5);
VALUES (1, 'Chewbacca', '', 'https://www.superherodb.com/pictures2/portraits/10/050/10466.jpg', 'Agility, Longevity, Marksmanship, Natural Weapons, Stealth, Super Strength, Weapons Master', 5);
INSERT INTO hero(id, name, otherName, picture, powers, level)
VALUES (nextval('hibernate_sequence'), 'Angel Salvadore', 'Angel Salvadore Bohusk', 'https://www.superherodb.com/pictures2/portraits/10/050/1406.jpg', 'Animal Attributes, Animal Oriented Powers, Flight, Regeneration, Toxin and Disease Control', 4);
VALUES (2, 'Angel Salvadore', 'Angel Salvadore Bohusk', 'https://www.superherodb.com/pictures2/portraits/10/050/1406.jpg', 'Animal Attributes, Animal Oriented Powers, Flight, Regeneration, Toxin and Disease Control', 4);
INSERT INTO hero(id, name, otherName, picture, powers, level)
VALUES (nextval('hibernate_sequence'), 'Bill Harken', '', 'https://www.superherodb.com/pictures2/portraits/10/050/1527.jpg', 'Super Speed, Super Strength, Toxin and Disease Resistance', 6);
VALUES (3, 'Bill Harken', '', 'https://www.superherodb.com/pictures2/portraits/10/050/1527.jpg', 'Super Speed, Super Strength, Toxin and Disease Resistance', 6);
-- end::adocSQL[]
INSERT INTO hero(id, name, otherName, picture, powers, level)
VALUES (nextval('hibernate_sequence'), 'Galadriel', '', 'https://www.superherodb.com/pictures2/portraits/11/050/11796.jpg', 'Danger Sense, Immortality, Intelligence, Invisibility, Magic, Precognition, Telekinesis, Telepathy', 17);
VALUES (4, 'Galadriel', '', 'https://www.superherodb.com/pictures2/portraits/11/050/11796.jpg', 'Danger Sense, Immortality, Intelligence, Invisibility, Magic, Precognition, Telekinesis, Telepathy', 17);
alter sequence hero_SEQ restart with 5;
2 changes: 1 addition & 1 deletion extensions/hibernate-reactive/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</dependency>
<dependency>
<groupId>org.hibernate.reactive</groupId>
<artifactId>hibernate-reactive-core-jakarta</artifactId>
<artifactId>hibernate-reactive-core</artifactId>
<exclusions>
<!-- Make sure Quarkus can manage Mutiny via quarkus-mutiny -->
<exclusion>
Expand Down
Loading

0 comments on commit 4799cd8

Please sign in to comment.