Skip to content

Commit

Permalink
Merge pull request #33140 from stuartwdouglas/static-fix
Browse files Browse the repository at this point in the history
Fix Hibernate Reactive dev mode
  • Loading branch information
geoand authored May 7, 2023
2 parents 1d99246 + fcd2808 commit 0951b3d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
import io.quarkus.deployment.util.JandexUtil;
import io.quarkus.gizmo.ClassCreator;
import io.quarkus.hibernate.orm.deployment.HibernateOrmEnabled;
Expand Down Expand Up @@ -208,6 +209,12 @@ void buildNamedQueryMap(List<PanacheNamedQueryEntityClassBuildStep> namedQueryEn
panacheHibernateRecorder.setNamedQueryMap(namedQueryMap);
}

@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void shutdown(ShutdownContextBuildItem shutdownContextBuildItem, PanacheHibernateRecorder panacheHibernateRecorder) {
panacheHibernateRecorder.clear(shutdownContextBuildItem);
}

private void lookupNamedQueries(CombinedIndexBuildItem index, DotName name, Set<String> namedQueries) {
ClassInfo classInfo = index.getComputingIndex().getClassByName(name);
if (classInfo == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
import java.util.Map;
import java.util.Set;

import io.quarkus.runtime.ShutdownContext;
import io.quarkus.runtime.annotations.Recorder;

@Recorder
public class PanacheHibernateRecorder {
public void setNamedQueryMap(Map<String, Set<String>> namedQueryMap) {
NamedQueryUtil.setNamedQueryMap(namedQueryMap);
}

public void clear(ShutdownContext shutdownContext) {
shutdownContext.addShutdownTask(new Runnable() {
@Override
public void run() {
SessionOperations.clear();
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,8 @@ static Mutiny.SessionFactory getSessionFactory() {
return SESSION_FACTORY.get();
}

static void clear() {
SESSION_FACTORY.clear();
SESSION_KEY.clear();
}
}

0 comments on commit 0951b3d

Please sign in to comment.