Search in sources :

Example 1 with StageSessionFactoryImpl

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));
}
Also used : MutinyValueGenerator(org.hibernate.reactive.tuple.MutinyValueGenerator) StageSessionFactoryImpl(org.hibernate.reactive.stage.impl.StageSessionFactoryImpl) StageSessionImpl(org.hibernate.reactive.stage.impl.StageSessionImpl) Mutiny(org.hibernate.reactive.mutiny.Mutiny) CompletionStage(java.util.concurrent.CompletionStage) Stage(org.hibernate.reactive.stage.Stage) MutinySessionImpl(org.hibernate.reactive.mutiny.impl.MutinySessionImpl) StageValueGenerator(org.hibernate.reactive.tuple.StageValueGenerator) MutinySessionFactoryImpl(org.hibernate.reactive.mutiny.impl.MutinySessionFactoryImpl) Session(org.hibernate.Session) ReactiveSession(org.hibernate.reactive.session.ReactiveSession)

Aggregations

CompletionStage (java.util.concurrent.CompletionStage)1 Session (org.hibernate.Session)1 Mutiny (org.hibernate.reactive.mutiny.Mutiny)1 MutinySessionFactoryImpl (org.hibernate.reactive.mutiny.impl.MutinySessionFactoryImpl)1 MutinySessionImpl (org.hibernate.reactive.mutiny.impl.MutinySessionImpl)1 ReactiveSession (org.hibernate.reactive.session.ReactiveSession)1 Stage (org.hibernate.reactive.stage.Stage)1 StageSessionFactoryImpl (org.hibernate.reactive.stage.impl.StageSessionFactoryImpl)1 StageSessionImpl (org.hibernate.reactive.stage.impl.StageSessionImpl)1 MutinyValueGenerator (org.hibernate.reactive.tuple.MutinyValueGenerator)1 StageValueGenerator (org.hibernate.reactive.tuple.StageValueGenerator)1