Skip to content

Commit 280a186

Browse files
mbelladeSanne
authored andcommitted
Hibernate ORM dev only module fixes
Main change is `HibernateOrmDevIntegrator` so we don't have to have a cyclic dependency on it in the runtime module
1 parent 67c0c1c commit 280a186

File tree

13 files changed

+76
-84
lines changed

13 files changed

+76
-84
lines changed

extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
import io.quarkus.hibernate.orm.deployment.integration.HibernateOrmIntegrationStaticConfiguredBuildItem;
114114
import io.quarkus.hibernate.orm.deployment.spi.AdditionalJpaModelBuildItem;
115115
import io.quarkus.hibernate.orm.deployment.spi.DatabaseKindDialectBuildItem;
116+
import io.quarkus.hibernate.orm.dev.HibernateOrmDevIntegrator;
116117
import io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder;
117118
import io.quarkus.hibernate.orm.runtime.HibernateOrmRuntimeConfig;
118119
import io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil;
@@ -125,7 +126,6 @@
125126
import io.quarkus.hibernate.orm.runtime.config.DialectVersions;
126127
import io.quarkus.hibernate.orm.runtime.customized.FormatMapperKind;
127128
import io.quarkus.hibernate.orm.runtime.customized.JsonFormatterCustomizationCheck;
128-
import io.quarkus.hibernate.orm.runtime.dev.HibernateOrmDevIntegrator;
129129
import io.quarkus.hibernate.orm.runtime.graal.RegisterServicesForReflectionFeature;
130130
import io.quarkus.hibernate.orm.runtime.integration.HibernateOrmIntegrationStaticDescriptor;
131131
import io.quarkus.hibernate.orm.runtime.migration.MultiTenancyStrategy;

extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/dev/HibernateOrmDevUIProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import io.quarkus.hibernate.orm.deployment.HibernateOrmConfig;
1616
import io.quarkus.hibernate.orm.deployment.HibernateOrmEnabled;
1717
import io.quarkus.hibernate.orm.deployment.PersistenceUnitDescriptorBuildItem;
18+
import io.quarkus.hibernate.orm.dev.HibernateOrmDevInfoCreateDDLSupplier;
19+
import io.quarkus.hibernate.orm.dev.ui.HibernateOrmDevJsonRpcService;
1820
import io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil;
19-
import io.quarkus.hibernate.orm.runtime.dev.HibernateOrmDevInfoCreateDDLSupplier;
20-
import io.quarkus.hibernate.orm.runtime.dev.ui.HibernateOrmDevJsonRpcService;
2121

2222
@BuildSteps(onlyIf = { HibernateOrmEnabled.class, IsLocalDevelopment.class })
2323
public class HibernateOrmDevUIProcessor {

extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/dev/HibernateOrmDevInfoServiceTestResource.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import jakarta.ws.rs.core.MediaType;
1111

1212
import io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil;
13-
import io.quarkus.hibernate.orm.runtime.dev.HibernateOrmDevController;
14-
import io.quarkus.hibernate.orm.runtime.dev.HibernateOrmDevInfo;
1513

1614
@Path("/dev-info")
1715
public class HibernateOrmDevInfoServiceTestResource {

extensions/hibernate-orm/runtime-dev/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
</dependency>
2020
<dependency>
2121
<groupId>io.quarkus</groupId>
22-
<artifactId>quarkus-vertx-http-dev</artifactId>
22+
<artifactId>quarkus-devui</artifactId>
23+
<optional>true</optional>
2324
</dependency>
2425
<dependency>
2526
<groupId>com.fasterxml.jackson.core</groupId>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.quarkus.hibernate.orm.runtime.dev;
1+
package io.quarkus.hibernate.orm.dev;
22

33
import java.io.PrintWriter;
44
import java.io.StringWriter;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.quarkus.hibernate.orm.runtime.dev;
1+
package io.quarkus.hibernate.orm.dev;
22

33
import java.util.ArrayList;
44
import java.util.Collection;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.quarkus.hibernate.orm.runtime.dev;
1+
package io.quarkus.hibernate.orm.dev;
22

33
import java.util.Collection;
44
import java.util.Objects;
Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,35 @@
1-
package io.quarkus.hibernate.orm.runtime.dev;
1+
package io.quarkus.hibernate.orm.dev;
22

33
import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_LOAD_SCRIPT_SOURCE;
44

5-
import java.util.Map;
6-
import java.util.concurrent.ConcurrentHashMap;
7-
85
import org.hibernate.boot.Metadata;
96
import org.hibernate.boot.spi.BootstrapContext;
107
import org.hibernate.cfg.AvailableSettings;
118
import org.hibernate.engine.spi.SessionFactoryImplementor;
129
import org.hibernate.integrator.spi.Integrator;
1310
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
1411

12+
import io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder;
1513
import io.quarkus.hibernate.orm.runtime.boot.QuarkusPersistenceUnitDescriptor;
1614

1715
public class HibernateOrmDevIntegrator implements Integrator {
18-
private static final Map<String, QuarkusPersistenceUnitDescriptor> puDescriptorMap = new ConcurrentHashMap<>();
19-
20-
public static void clearPuMap() {
21-
puDescriptorMap.clear();
22-
}
23-
24-
public static void mapPersistenceUnit(String pu, QuarkusPersistenceUnitDescriptor descriptor) {
25-
puDescriptorMap.put(pu, descriptor);
26-
}
27-
2816
@Override
29-
public void integrate(Metadata metadata, BootstrapContext bootstrapContext,
30-
SessionFactoryImplementor sessionFactoryImplementor) {
31-
String name = (String) sessionFactoryImplementor.getProperties()
17+
public void integrate(Metadata metadata, BootstrapContext bootstrapContext, SessionFactoryImplementor sf) {
18+
String name = (String) sf.getProperties()
3219
.get(AvailableSettings.PERSISTENCE_UNIT_NAME);
3320
HibernateOrmDevController.get().pushPersistenceUnit(
34-
sessionFactoryImplementor,
35-
puDescriptorMap.get(name),
21+
sf,
22+
getPersistenceUnitDescriptor(name, sf),
3623
name,
3724
metadata,
38-
sessionFactoryImplementor.getServiceRegistry(),
39-
(String) sessionFactoryImplementor.getProperties().get(JAKARTA_HBM2DDL_LOAD_SCRIPT_SOURCE));
25+
sf.getServiceRegistry(),
26+
(String) sf.getProperties().get(JAKARTA_HBM2DDL_LOAD_SCRIPT_SOURCE));
27+
}
28+
29+
private static QuarkusPersistenceUnitDescriptor getPersistenceUnitDescriptor(String name, SessionFactoryImplementor sf) {
30+
// This is not great but avoids needing to depend on reactive
31+
boolean isReactive = sf.getClass().getPackage().getName().contains("reactive");
32+
return PersistenceUnitsHolder.getPersistenceUnitDescriptor(name, isReactive);
4033
}
4134

4235
@Override
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.quarkus.hibernate.orm.runtime.dev.ui;
1+
package io.quarkus.hibernate.orm.dev.ui;
22

33
import static org.hibernate.query.sqm.internal.SqmUtil.isMutation;
44

@@ -25,9 +25,9 @@
2525
import io.quarkus.devui.runtime.comms.JsonRpcMessage;
2626
import io.quarkus.devui.runtime.comms.JsonRpcRouter;
2727
import io.quarkus.devui.runtime.comms.MessageType;
28+
import io.quarkus.hibernate.orm.dev.HibernateOrmDevController;
29+
import io.quarkus.hibernate.orm.dev.HibernateOrmDevInfo;
2830
import io.quarkus.hibernate.orm.runtime.customized.QuarkusConnectionProvider;
29-
import io.quarkus.hibernate.orm.runtime.dev.HibernateOrmDevController;
30-
import io.quarkus.hibernate.orm.runtime.dev.HibernateOrmDevInfo;
3131
import io.quarkus.runtime.LaunchMode;
3232

3333
public class HibernateOrmDevJsonRpcService {

extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRecorder.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import io.quarkus.arc.runtime.BeanContainerListener;
3030
import io.quarkus.hibernate.orm.PersistenceUnit;
3131
import io.quarkus.hibernate.orm.runtime.boot.QuarkusPersistenceUnitDefinition;
32-
import io.quarkus.hibernate.orm.runtime.dev.HibernateOrmDevIntegrator;
3332
import io.quarkus.hibernate.orm.runtime.integration.HibernateOrmIntegrationRuntimeDescriptor;
3433
import io.quarkus.hibernate.orm.runtime.migration.MultiTenancyStrategy;
3534
import io.quarkus.hibernate.orm.runtime.proxies.PreGeneratedProxies;
@@ -76,12 +75,10 @@ public void setupPersistenceProvider(
7675
public BeanContainerListener initMetadata(List<QuarkusPersistenceUnitDefinition> parsedPersistenceXmlDescriptors,
7776
Scanner scanner, Collection<Class<? extends Integrator>> additionalIntegrators) {
7877
SchemaManagementIntegrator.clearDsMap();
79-
HibernateOrmDevIntegrator.clearPuMap();
8078
for (QuarkusPersistenceUnitDefinition i : parsedPersistenceXmlDescriptors) {
8179
if (i.getConfig().getDataSource().isPresent()) {
8280
SchemaManagementIntegrator.mapDatasource(i.getConfig().getDataSource().get(), i.getName());
8381
}
84-
HibernateOrmDevIntegrator.mapPersistenceUnit(i.getName(), i.getPersistenceUnitDescriptor());
8582
}
8683
return new BeanContainerListener() {
8784
@Override

0 commit comments

Comments
 (0)