Search in sources :

Example 11 with HQLQueryPlan

use of org.hibernate.engine.query.spi.HQLQueryPlan in project hibernate-orm by hibernate.

the class AbstractProducedQuery method getQueryParameters.

public QueryParameters getQueryParameters() {
    final HQLQueryPlan entityGraphHintedQueryPlan;
    if (entityGraphQueryHint == null) {
        entityGraphHintedQueryPlan = null;
    } else {
        queryParameterBindings.verifyParametersBound(false);
        // todo : ideally we'd update the instance state related to queryString but that is final atm
        final String expandedQuery = queryParameterBindings.expandListValuedParameters(getQueryString(), getProducer());
        entityGraphHintedQueryPlan = new HQLQueryPlan(expandedQuery, false, getProducer().getLoadQueryInfluencers().getEnabledFilters(), getProducer().getFactory(), entityGraphQueryHint);
    }
    QueryParameters queryParameters = new QueryParameters(getPositionalParameterTypes(), getPositionalParameterValues(), getNamedParameterMap(), getLockOptions(), queryOptions, true, isReadOnly(), cacheable, cacheRegion, comment, dbHints, null, optionalObject, optionalEntityName, optionalId, resultTransformer);
    queryParameters.setQueryPlan(entityGraphHintedQueryPlan);
    if (passDistinctThrough != null) {
        queryParameters.setPassDistinctThrough(passDistinctThrough);
    }
    return queryParameters;
}
Also used : HQLQueryPlan(org.hibernate.engine.query.spi.HQLQueryPlan) QueryParameters(org.hibernate.engine.spi.QueryParameters)

Example 12 with HQLQueryPlan

use of org.hibernate.engine.query.spi.HQLQueryPlan in project hibernate-orm by hibernate.

the class TupleSupportTest method testImplicitTupleNotInList.

@Test
public void testImplicitTupleNotInList() {
    final String hql = "from TheEntity e where e.compositeValue not in (:p1,:p2)";
    HQLQueryPlan queryPlan = ((SessionFactoryImplementor) sessionFactory).getQueryPlanCache().getHQLQueryPlan(hql, false, Collections.<String, Filter>emptyMap());
    assertEquals(1, queryPlan.getSqlStrings().length);
    System.out.println(" SQL : " + queryPlan.getSqlStrings()[0]);
    assertTrue(queryPlan.getSqlStrings()[0].contains("<>"));
}
Also used : HQLQueryPlan(org.hibernate.engine.query.spi.HQLQueryPlan) Test(org.junit.Test)

Example 13 with HQLQueryPlan

use of org.hibernate.engine.query.spi.HQLQueryPlan in project hibernate-orm by hibernate.

the class StatelessSessionImpl method scroll.

@Override
public ScrollableResultsImplementor scroll(String query, QueryParameters queryParameters) throws HibernateException {
    checkOpen();
    HQLQueryPlan plan = getQueryPlan(query, false);
    return plan.performScroll(queryParameters, this);
}
Also used : HQLQueryPlan(org.hibernate.engine.query.spi.HQLQueryPlan)

Example 14 with HQLQueryPlan

use of org.hibernate.engine.query.spi.HQLQueryPlan in project hibernate-orm by hibernate.

the class StatelessSessionImpl method list.

/////////////////////////////////////////////////////////////////////////////////////////////////////
//TODO: COPY/PASTE FROM SessionImpl, pull up!
@Override
public List list(String query, QueryParameters queryParameters) throws HibernateException {
    checkOpen();
    queryParameters.validateParameters();
    HQLQueryPlan plan = getQueryPlan(query, false);
    boolean success = false;
    List results = Collections.EMPTY_LIST;
    try {
        results = plan.performList(queryParameters, this);
        success = true;
    } finally {
        afterOperation(success);
    }
    temporaryPersistenceContext.clear();
    return results;
}
Also used : HQLQueryPlan(org.hibernate.engine.query.spi.HQLQueryPlan) List(java.util.List)

Example 15 with HQLQueryPlan

use of org.hibernate.engine.query.spi.HQLQueryPlan in project hibernate-orm by hibernate.

the class SessionImpl method iterate.

@Override
public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException {
    checkOpenOrWaitingForAutoClose();
    checkTransactionSynchStatus();
    queryParameters.validateParameters();
    HQLQueryPlan plan = queryParameters.getQueryPlan();
    if (plan == null) {
        plan = getQueryPlan(query, true);
    }
    autoFlushIfRequired(plan.getQuerySpaces());
    //stops flush being called multiple times if this method is recursively called
    dontFlushFromFind++;
    try {
        return plan.performIterate(queryParameters, this);
    } finally {
        delayedAfterCompletion();
        dontFlushFromFind--;
    }
}
Also used : HQLQueryPlan(org.hibernate.engine.query.spi.HQLQueryPlan)

Aggregations

HQLQueryPlan (org.hibernate.engine.query.spi.HQLQueryPlan)17 Test (org.junit.Test)9 Session (org.hibernate.Session)4 QueryTranslator (org.hibernate.hql.spi.QueryTranslator)3 List (java.util.List)2 QueryPlanCache (org.hibernate.engine.query.spi.QueryPlanCache)2 TestForIssue (org.hibernate.testing.TestForIssue)2 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 QueryParameters (org.hibernate.engine.spi.QueryParameters)1 SQLGrammarException (org.hibernate.exception.SQLGrammarException)1 RequiresDialectFeature (org.hibernate.testing.RequiresDialectFeature)1 SkipForDialect (org.hibernate.testing.SkipForDialect)1