Search in sources :

Example 1 with SqmCreationOptions

use of org.hibernate.query.hql.spi.SqmCreationOptions in project hibernate-orm by hibernate.

the class QueryEngine method from.

public static QueryEngine from(SessionFactoryImplementor sessionFactory, MetadataImplementor metadata) {
    final QueryEngineOptions queryEngineOptions = sessionFactory.getSessionFactoryOptions();
    final SqmCreationOptions sqmCreationOptions = new SqmCreationOptionsStandard(sessionFactory);
    final Dialect dialect = sessionFactory.getJdbcServices().getDialect();
    final HqlTranslator hqlTranslator = resolveHqlTranslator(queryEngineOptions, dialect, sessionFactory, sqmCreationOptions);
    final SqmTranslatorFactory sqmTranslatorFactory = resolveSqmTranslatorFactory(queryEngineOptions, dialect);
    final SqmFunctionRegistry customSqmFunctionRegistry;
    if (queryEngineOptions.getCustomSqmFunctionRegistry() == null) {
        final Map<String, SqmFunctionDescriptor> customSqlFunctionMap = queryEngineOptions.getCustomSqlFunctionMap();
        if (customSqlFunctionMap == null || customSqlFunctionMap.isEmpty()) {
            customSqmFunctionRegistry = null;
        } else {
            customSqmFunctionRegistry = new SqmFunctionRegistry();
            customSqlFunctionMap.forEach(customSqmFunctionRegistry::register);
        }
    } else {
        customSqmFunctionRegistry = queryEngineOptions.getCustomSqmFunctionRegistry();
    }
    return new QueryEngine(sessionFactory.getUuid(), sessionFactory.getName(), sessionFactory.getSessionFactoryOptions().getJpaCompliance(), () -> sessionFactory.getRuntimeMetamodels().getJpaMetamodel(), sessionFactory.getSessionFactoryOptions().getCriteriaValueHandlingMode(), sessionFactory.getSessionFactoryOptions().getPreferredSqlTypeCodeForBoolean(), metadata.buildNamedQueryRepository(sessionFactory), hqlTranslator, sqmTranslatorFactory, sessionFactory.getServiceRegistry().getService(NativeQueryInterpreter.class), buildInterpretationCache(sessionFactory::getStatistics, sessionFactory.getProperties()), metadata.getTypeConfiguration(), dialect, customSqmFunctionRegistry, sessionFactory.getServiceRegistry());
}
Also used : SqmCreationOptionsStandard(org.hibernate.query.sqm.internal.SqmCreationOptionsStandard) SqmFunctionDescriptor(org.hibernate.query.sqm.function.SqmFunctionDescriptor) NativeQueryInterpreter(org.hibernate.engine.query.spi.NativeQueryInterpreter) SqmCreationOptions(org.hibernate.query.hql.spi.SqmCreationOptions) HqlTranslator(org.hibernate.query.hql.HqlTranslator) StandardHqlTranslator(org.hibernate.query.hql.internal.StandardHqlTranslator) Dialect(org.hibernate.dialect.Dialect) StandardSqmTranslatorFactory(org.hibernate.query.sqm.sql.StandardSqmTranslatorFactory) SqmTranslatorFactory(org.hibernate.query.sqm.sql.SqmTranslatorFactory) SqmFunctionRegistry(org.hibernate.query.sqm.function.SqmFunctionRegistry)

Aggregations

Dialect (org.hibernate.dialect.Dialect)1 NativeQueryInterpreter (org.hibernate.engine.query.spi.NativeQueryInterpreter)1 HqlTranslator (org.hibernate.query.hql.HqlTranslator)1 StandardHqlTranslator (org.hibernate.query.hql.internal.StandardHqlTranslator)1 SqmCreationOptions (org.hibernate.query.hql.spi.SqmCreationOptions)1 SqmFunctionDescriptor (org.hibernate.query.sqm.function.SqmFunctionDescriptor)1 SqmFunctionRegistry (org.hibernate.query.sqm.function.SqmFunctionRegistry)1 SqmCreationOptionsStandard (org.hibernate.query.sqm.internal.SqmCreationOptionsStandard)1 SqmTranslatorFactory (org.hibernate.query.sqm.sql.SqmTranslatorFactory)1 StandardSqmTranslatorFactory (org.hibernate.query.sqm.sql.StandardSqmTranslatorFactory)1