-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31454 from Sanne/HibernateReactive2
Hibernate Reactive 2.0.0.Alpha2 & re-enabling all HR modules
- Loading branch information
Showing
41 changed files
with
584 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/Dialects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...eployment/src/test/java/io/quarkus/hibernate/reactive/services/ServiceInitiatorsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
extensions/hibernate-reactive/deployment/src/test/resources/complexMultilineImports.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.