Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
blafond committed Jul 13, 2023
1 parent e88effd commit c0c393a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.hibernate.query.named.NamedQueryMemento;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.reactive.loader.ast.spi.ReactiveSingleIdEntityLoader;
import org.hibernate.reactive.query.sql.internal.ReactiveNativeQueryImpl;

import jakarta.persistence.Parameter;

Expand Down Expand Up @@ -51,7 +52,7 @@ public CompletionStage<T> load(Object pkValue, LockOptions lockOptions, Boolean
query.setParameter( (Parameter<Object>) query.getParameters().iterator().next(), pkValue );
query.setHibernateFlushMode( FlushMode.MANUAL );

return completedFuture( query.uniqueResult() );
return (( ReactiveNativeQueryImpl)query).reactiveUnique();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public NamedQueryMemento resolve(
SessionFactoryImplementor sessionFactory,
MetadataImplementor bootMetamodel,
String registrationName) {
return delegate.resolve( sessionFactory, bootMetamodel, registrationName );
return new ReactiveNamedNativeQueryMemento( (NamedNativeQueryMemento)delegate.resolve( sessionFactory, bootMetamodel, registrationName ) );
}

@Override
Expand Down

2 comments on commit c0c393a

@DavideD
Copy link

@DavideD DavideD commented on c0c393a Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this method is called only for native queries?
It returns a NamedQueryMemento that's a superclass for NamedNativeQueryMemento and NamedSqmQueryMemento.
I think we need a .wrap that accept it and does something like:

if ( memento instanceof NamedNativeQueryMemento) {
    return wrap((NamedNativeQueryMemento) memento);
}
if (memento instanceof NamedSqmQueryMemento) {
    return wrap((NamedSqmQueryMemento) memento);
}
// What do we do here? Throw an exception? I don't think we support NamedCallebleQueryMemento

@blafond
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give that a shot

Please sign in to comment.