fix a minor typing issue in SessionFactoryImpl
This commit is contained in:
parent
fc9229e9f4
commit
2a904a46b2
|
@ -27,6 +27,7 @@ import java.util.function.Supplier;
|
|||
import javax.naming.Reference;
|
||||
import javax.naming.StringRefAddr;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||
import org.hibernate.EntityNameResolver;
|
||||
import org.hibernate.FlushMode;
|
||||
|
@ -93,13 +94,11 @@ import org.hibernate.proxy.LazyInitializer;
|
|||
import org.hibernate.query.hql.spi.SqmQueryImplementor;
|
||||
import org.hibernate.query.internal.QueryEngineImpl;
|
||||
import org.hibernate.query.named.NamedObjectRepository;
|
||||
import org.hibernate.query.named.NamedQueryMemento;
|
||||
import org.hibernate.query.spi.QueryEngine;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.query.sql.spi.NativeQueryImplementor;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.query.sqm.spi.NamedSqmQueryMemento;
|
||||
import org.hibernate.relational.SchemaManager;
|
||||
import org.hibernate.relational.internal.SchemaManagerImpl;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
|
@ -923,8 +922,8 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
public void addNamedQuery(String name, Query query) {
|
||||
validateNotClosed();
|
||||
|
||||
// NOTE : we use Query#unwrap here (rather than direct type checking) to account for possibly wrapped
|
||||
// query implementations
|
||||
// NOTE : we use Query#unwrap here (rather than direct type checking)
|
||||
// to account for possibly wrapped query implementations
|
||||
|
||||
// first, handle StoredProcedureQuery
|
||||
final NamedObjectRepository namedObjectRepository = getQueryEngine().getNamedObjectRepository();
|
||||
|
@ -941,24 +940,25 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
|
||||
// then try as a native-SQL or JPQL query
|
||||
try {
|
||||
final QueryImplementor<?> hibernateQuery = query.unwrap( QueryImplementor.class );
|
||||
if ( hibernateQuery != null ) {
|
||||
final QueryImplementor<?> queryImplementor = query.unwrap( QueryImplementor.class );
|
||||
if ( queryImplementor != null ) {
|
||||
// create and register the proper NamedQueryDefinition...
|
||||
if ( hibernateQuery instanceof NativeQueryImplementor ) {
|
||||
if ( queryImplementor instanceof NativeQueryImplementor<?> nativeQueryImplementor ) {
|
||||
namedObjectRepository.registerNativeQueryMemento(
|
||||
name,
|
||||
( (NativeQueryImplementor<?>) hibernateQuery ).toMemento( name )
|
||||
nativeQueryImplementor.toMemento( name )
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
final NamedQueryMemento namedQueryMemento =
|
||||
( (SqmQueryImplementor<?>) hibernateQuery ).toMemento( name );
|
||||
else if ( queryImplementor instanceof SqmQueryImplementor<?> sqmQueryImplementor ) {
|
||||
namedObjectRepository.registerSqmQueryMemento(
|
||||
name,
|
||||
(NamedSqmQueryMemento) namedQueryMemento
|
||||
sqmQueryImplementor.toMemento( name )
|
||||
);
|
||||
}
|
||||
else {
|
||||
throw new AssertionFailure("unknown QueryImplementor");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ import org.hibernate.query.QueryParameter;
|
|||
import org.hibernate.query.ResultListTransformer;
|
||||
import org.hibernate.query.TupleTransformer;
|
||||
import org.hibernate.query.named.NameableQuery;
|
||||
import org.hibernate.query.named.NamedQueryMemento;
|
||||
import org.hibernate.query.spi.ParameterMetadataImplementor;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.query.spi.SqmQuery;
|
||||
import org.hibernate.query.sqm.spi.NamedSqmQueryMemento;
|
||||
import org.hibernate.query.sqm.tree.SqmStatement;
|
||||
import org.hibernate.transform.ResultTransformer;
|
||||
|
||||
|
@ -42,7 +42,7 @@ import jakarta.persistence.TemporalType;
|
|||
*/
|
||||
public interface SqmQueryImplementor<R> extends QueryImplementor<R>, SqmQuery, NameableQuery {
|
||||
@Override
|
||||
NamedQueryMemento<R> toMemento(String name);
|
||||
NamedSqmQueryMemento<R> toMemento(String name);
|
||||
|
||||
@Override
|
||||
ParameterMetadataImplementor getParameterMetadata();
|
||||
|
|
|
@ -55,7 +55,6 @@ import org.hibernate.query.hql.internal.QuerySplitter;
|
|||
import org.hibernate.query.hql.spi.SqmQueryImplementor;
|
||||
import org.hibernate.query.internal.DelegatingDomainQueryExecutionContext;
|
||||
import org.hibernate.query.internal.ParameterMetadataImpl;
|
||||
import org.hibernate.query.named.NamedQueryMemento;
|
||||
import org.hibernate.query.spi.DelegatingQueryOptions;
|
||||
import org.hibernate.query.spi.DomainQueryExecutionContext;
|
||||
import org.hibernate.query.spi.HqlInterpretation;
|
||||
|
@ -70,6 +69,7 @@ import org.hibernate.query.spi.SelectQueryPlan;
|
|||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.internal.SqmInterpretationsKey.InterpretationsKeySource;
|
||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
||||
import org.hibernate.query.sqm.spi.NamedSqmQueryMemento;
|
||||
import org.hibernate.query.sqm.tree.AbstractSqmDmlStatement;
|
||||
import org.hibernate.query.sqm.tree.SqmCopyContext;
|
||||
import org.hibernate.query.sqm.tree.SqmStatement;
|
||||
|
@ -890,7 +890,7 @@ public class QuerySqmImpl<R>
|
|||
// Named query externalization
|
||||
|
||||
@Override
|
||||
public NamedQueryMemento<R> toMemento(String name) {
|
||||
public NamedSqmQueryMemento<R> toMemento(String name) {
|
||||
if ( CRITERIA_HQL_STRING.equals( getQueryString() ) ) {
|
||||
final SqmStatement<R> sqmStatement;
|
||||
if ( !getSession().isCriteriaCopyTreeEnabled() ) {
|
||||
|
|
Loading…
Reference in New Issue