Search in sources :

Example 1 with NamedCallableQueryMemento

use of org.hibernate.procedure.spi.NamedCallableQueryMemento in project hibernate-orm by hibernate.

the class NamedObjectRepositoryImpl method prepare.

@Override
public void prepare(SessionFactoryImplementor sessionFactory, MetadataImplementor bootMetamodel, BootstrapContext bootstrapContext) {
    bootMetamodel.visitNamedHqlQueryDefinitions(namedHqlQueryDefinition -> {
        final NamedSqmQueryMemento resolved = namedHqlQueryDefinition.resolve(sessionFactory);
        sqmMementoMap.put(namedHqlQueryDefinition.getRegistrationName(), resolved);
    });
    bootMetamodel.visitNamedNativeQueryDefinitions(namedNativeQueryDefinition -> {
        final NamedNativeQueryMemento resolved = namedNativeQueryDefinition.resolve(sessionFactory);
        sqlMementoMap.put(namedNativeQueryDefinition.getRegistrationName(), resolved);
    });
    bootMetamodel.visitNamedResultSetMappingDefinition(namedResultSetMappingDefinition -> {
        final NamedResultSetMappingMemento resolved = namedResultSetMappingDefinition.resolve(() -> sessionFactory);
        resultSetMappingMementoMap.put(namedResultSetMappingDefinition.getRegistrationName(), resolved);
    });
    bootMetamodel.visitNamedProcedureCallDefinition(namedProcedureCallDefinition -> {
        final NamedCallableQueryMemento resolved = namedProcedureCallDefinition.resolve(sessionFactory);
        callableMementoMap.put(namedProcedureCallDefinition.getRegistrationName(), resolved);
    });
}
Also used : NamedSqmQueryMemento(org.hibernate.query.sqm.spi.NamedSqmQueryMemento) NamedNativeQueryMemento(org.hibernate.query.sql.spi.NamedNativeQueryMemento) NamedResultSetMappingMemento(org.hibernate.query.named.NamedResultSetMappingMemento) NamedCallableQueryMemento(org.hibernate.procedure.spi.NamedCallableQueryMemento)

Example 2 with NamedCallableQueryMemento

use of org.hibernate.procedure.spi.NamedCallableQueryMemento in project hibernate-orm by hibernate.

the class AbstractSharedSessionContract method getNamedProcedureCall.

@Override
@SuppressWarnings("UnnecessaryLocalVariable")
public ProcedureCall getNamedProcedureCall(String name) {
    checkOpen();
    final NamedCallableQueryMemento memento = factory.getQueryEngine().getNamedObjectRepository().getCallableQueryMemento(name);
    if (memento == null) {
        throw new IllegalArgumentException("Could not find named stored procedure call with that registration name : " + name);
    }
    final ProcedureCall procedureCall = memento.makeProcedureCall(this);
    // procedureCall.setComment( "Named stored procedure call [" + name + "]" );
    return procedureCall;
}
Also used : ProcedureCall(org.hibernate.procedure.ProcedureCall) NamedCallableQueryMemento(org.hibernate.procedure.spi.NamedCallableQueryMemento)

Example 3 with NamedCallableQueryMemento

use of org.hibernate.procedure.spi.NamedCallableQueryMemento in project hibernate-orm by hibernate.

the class NamedObjectRepositoryImpl method resolve.

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Prepare repository for use
@Override
public NamedQueryMemento resolve(SessionFactoryImplementor sessionFactory, MetadataImplementor bootMetamodel, String registrationName) {
    NamedQueryMemento namedQuery = sqlMementoMap.get(registrationName);
    if (namedQuery != null) {
        return namedQuery;
    }
    namedQuery = sqmMementoMap.get(registrationName);
    if (namedQuery != null) {
        return namedQuery;
    }
    namedQuery = callableMementoMap.get(registrationName);
    if (namedQuery != null) {
        return namedQuery;
    }
    final NamedHqlQueryDefinition namedHqlQueryDefinition = bootMetamodel.getNamedHqlQueryMapping(registrationName);
    if (namedHqlQueryDefinition != null) {
        final NamedSqmQueryMemento resolved = namedHqlQueryDefinition.resolve(sessionFactory);
        sqmMementoMap.put(namedHqlQueryDefinition.getRegistrationName(), resolved);
        return resolved;
    }
    final NamedNativeQueryDefinition namedNativeQueryDefinition = bootMetamodel.getNamedNativeQueryMapping(registrationName);
    if (namedNativeQueryDefinition != null) {
        final NamedNativeQueryMemento resolved = namedNativeQueryDefinition.resolve(sessionFactory);
        sqlMementoMap.put(namedNativeQueryDefinition.getRegistrationName(), resolved);
        return resolved;
    }
    final NamedProcedureCallDefinition namedCallableQueryDefinition = bootMetamodel.getNamedProcedureCallMapping(registrationName);
    if (namedCallableQueryDefinition != null) {
        final NamedCallableQueryMemento resolved = namedCallableQueryDefinition.resolve(sessionFactory);
        callableMementoMap.put(namedCallableQueryDefinition.getRegistrationName(), resolved);
        return resolved;
    }
    return null;
}
Also used : NamedSqmQueryMemento(org.hibernate.query.sqm.spi.NamedSqmQueryMemento) NamedHqlQueryDefinition(org.hibernate.boot.query.NamedHqlQueryDefinition) NamedNativeQueryMemento(org.hibernate.query.sql.spi.NamedNativeQueryMemento) NamedCallableQueryMemento(org.hibernate.procedure.spi.NamedCallableQueryMemento) NamedNativeQueryDefinition(org.hibernate.boot.query.NamedNativeQueryDefinition) NamedQueryMemento(org.hibernate.query.named.NamedQueryMemento) NamedProcedureCallDefinition(org.hibernate.boot.query.NamedProcedureCallDefinition)

Aggregations

NamedCallableQueryMemento (org.hibernate.procedure.spi.NamedCallableQueryMemento)3 NamedNativeQueryMemento (org.hibernate.query.sql.spi.NamedNativeQueryMemento)2 NamedSqmQueryMemento (org.hibernate.query.sqm.spi.NamedSqmQueryMemento)2 NamedHqlQueryDefinition (org.hibernate.boot.query.NamedHqlQueryDefinition)1 NamedNativeQueryDefinition (org.hibernate.boot.query.NamedNativeQueryDefinition)1 NamedProcedureCallDefinition (org.hibernate.boot.query.NamedProcedureCallDefinition)1 ProcedureCall (org.hibernate.procedure.ProcedureCall)1 NamedQueryMemento (org.hibernate.query.named.NamedQueryMemento)1 NamedResultSetMappingMemento (org.hibernate.query.named.NamedResultSetMappingMemento)1