use of org.hibernate.reactive.stage.impl.StageSessionFactoryImpl in project hibernate-reactive by hibernate.
the class ReactiveAbstractEntityPersister method generateValue.
default CompletionStage<?> generateValue(Object owner, SharedSessionContractImplementor session, InMemoryValueGenerationStrategy valueGenerationStrategy) {
final ValueGenerator<?> valueGenerator = valueGenerationStrategy.getValueGenerator();
if (valueGenerator instanceof StageValueGenerator) {
final StageSessionFactoryImpl stageFactory = new StageSessionFactoryImpl((SessionFactoryImpl) session.getFactory());
final Stage.Session stageSession = new StageSessionImpl((ReactiveSession) session, stageFactory);
return ((StageValueGenerator<?>) valueGenerator).generateValue(stageSession, owner);
}
if (valueGenerator instanceof MutinyValueGenerator) {
MutinySessionFactoryImpl mutinyFactory = new MutinySessionFactoryImpl((SessionFactoryImpl) session.getFactory());
Mutiny.Session mutinySession = new MutinySessionImpl((ReactiveSession) session, mutinyFactory);
return ((MutinyValueGenerator<?>) valueGenerator).generateValue(mutinySession, owner).subscribeAsCompletionStage();
}
// annotations. We need an alternative for Hibernate Reactive.
return completedFuture(valueGenerationStrategy.getValueGenerator().generateValue((Session) session, owner));
}
Aggregations