Package org.hibernate.engine.query.spi

Examples of org.hibernate.engine.query.spi.HQLQueryPlan


  }

  protected void resultClassChecking(Class resultClass, org.hibernate.Query hqlQuery) {
    // make sure the query is a select -> HHH-7192
    final SessionImplementor session = unwrap( SessionImplementor.class );
    final HQLQueryPlan queryPlan = session.getFactory().getQueryPlanCache().getHQLQueryPlan(
        hqlQuery.getQueryString(),
        false,
        session.getLoadQueryInfluencers().getEnabledFilters()
    );
    if ( queryPlan.getTranslators()[0].isManipulationStatement() ) {
      throw new IllegalArgumentException( "Update/delete queries cannot be typed" );
    }

    // do some return type validation checking
    if ( Object[].class.equals( resultClass ) ) {
      // no validation needed
    }
    else if ( Tuple.class.equals( resultClass ) ) {
      TupleBuilderTransformer tupleTransformer = new TupleBuilderTransformer( hqlQuery );
      hqlQuery.setResultTransformer( tupleTransformer  );
    }
    else {
      final Class dynamicInstantiationClass = queryPlan.getDynamicInstantiationResultType();
      if ( dynamicInstantiationClass != null ) {
        if ( ! resultClass.isAssignableFrom( dynamicInstantiationClass ) ) {
          throw new IllegalArgumentException(
              "Mismatch in requested result type [" + resultClass.getName() +
                  "] and actual result type [" + dynamicInstantiationClass.getName() + "]"
View Full Code Here


      else if ( Tuple.class.equals( resultClass ) ) {
        TupleBuilderTransformer tupleTransformer = new TupleBuilderTransformer( hqlQuery );
        hqlQuery.setResultTransformer( tupleTransformer  );
      }
      else {
        final HQLQueryPlan queryPlan = unwrap( SessionImplementor.class )
            .getFactory()
            .getQueryPlanCache()
            .getHQLQueryPlan( jpaqlString, false, null );
        final Class dynamicInstantiationClass = queryPlan.getDynamicInstantiationResultType();
        if ( dynamicInstantiationClass != null ) {
          if ( ! resultClass.isAssignableFrom( dynamicInstantiationClass ) ) {
            throw new IllegalArgumentException(
                "Mismatch in requested result type [" + resultClass.getName() +
                    "] and actual result type [" + dynamicInstantiationClass.getName() + "]"
View Full Code Here

  @Override
  public int executeUpdate(String query, QueryParameters queryParameters)
      throws HibernateException {
    errorIfClosed();
    queryParameters.validateParameters();
    HQLQueryPlan plan = getHQLQueryPlan( query, false );
    boolean success = false;
    int result = 0;
    try {
      result = plan.performExecuteUpdate( queryParameters, this );
      success = true;
    }
    finally {
      afterOperation(success);
    }
View Full Code Here

  @Override
  public List list(String query, QueryParameters queryParameters) throws HibernateException {
    errorIfClosed();
    queryParameters.validateParameters();
    HQLQueryPlan plan = getHQLQueryPlan( query, false );
    boolean success = false;
    List results = CollectionHelper.EMPTY_LIST;
    try {
      results = plan.performList( queryParameters, this );
      success = true;
    }
    finally {
      afterOperation(success);
    }
View Full Code Here

  }

  @Override
  public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException {
    errorIfClosed();
    HQLQueryPlan plan = getHQLQueryPlan( query, false );
    return plan.performScroll( queryParameters, this );
  }
View Full Code Here

  @Override
  public int executeUpdate(String query, QueryParameters queryParameters)
      throws HibernateException {
    errorIfClosed();
    queryParameters.validateParameters();
    HQLQueryPlan plan = getHQLQueryPlan( query, false );
    boolean success = false;
    int result = 0;
    try {
      result = plan.performExecuteUpdate( queryParameters, this );
      success = true;
    }
    finally {
      afterOperation(success);
    }
View Full Code Here

  @Override
  public List list(String query, QueryParameters queryParameters) throws HibernateException {
    errorIfClosed();
    queryParameters.validateParameters();
    HQLQueryPlan plan = getHQLQueryPlan( query, false );
    boolean success = false;
    List results = Collections.EMPTY_LIST;
    try {
      results = plan.performList( queryParameters, this );
      success = true;
    }
    finally {
      afterOperation(success);
    }
View Full Code Here

  }

  @Override
  public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException {
    errorIfClosed();
    HQLQueryPlan plan = getHQLQueryPlan( query, false );
    return plan.performScroll( queryParameters, this );
  }
View Full Code Here

  public List list(String query, QueryParameters queryParameters) throws HibernateException {
    errorIfClosed();
    checkTransactionSynchStatus();
    queryParameters.validateParameters();
    HQLQueryPlan plan = getHQLQueryPlan( query, false );
    autoFlushIfRequired( plan.getQuerySpaces() );

    List results = Collections.EMPTY_LIST;
    boolean success = false;

    dontFlushFromFind++;   //stops flush being called multiple times if this method is recursively called
    try {
      results = plan.performList( queryParameters, this );
      success = true;
    }
    finally {
      dontFlushFromFind--;
      afterOperation(success);
View Full Code Here

  public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException {
    errorIfClosed();
    checkTransactionSynchStatus();
    queryParameters.validateParameters();
    HQLQueryPlan plan = getHQLQueryPlan( query, false );
    autoFlushIfRequired( plan.getQuerySpaces() );

    boolean success = false;
    int result = 0;
    try {
      result = plan.performExecuteUpdate( queryParameters, this );
      success = true;
    }
    finally {
      afterOperation(success);
    }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.query.spi.HQLQueryPlan

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.