Package org.hibernate.engine

Examples of org.hibernate.engine.NamedQueryDefinition


    }
  }

  public Query getNamedQuery(String queryName) throws MappingException {
    errorIfClosed();
    NamedQueryDefinition nqd = factory.getNamedQuery( queryName );
    final Query query;
    if ( nqd != null ) {
      String queryString = nqd.getQueryString();
      query = new QueryImpl(
          queryString,
              nqd.getFlushMode(),
              this,
              getHQLQueryPlan( queryString, false ).getParameterMetadata()
      );
      query.setComment( "named HQL query " + queryName );
    }
View Full Code Here


    Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
    String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
    Attribute cmAtt = queryElem.attribute( "comment" );
    String comment = cmAtt == null ? null : cmAtt.getValue();

    NamedQueryDefinition namedQuery = new NamedQueryDefinition(
        query,
        cacheable,
        region,
        timeout,
        fetchSize,
View Full Code Here

    Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
    String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
    Attribute cmAtt = queryElem.attribute( "comment" );
    String comment = cmAtt == null ? null : cmAtt.getValue();

    NamedQueryDefinition namedQuery = new NamedQueryDefinition(
        query,
        cacheable,
        region,
        timeout,
        fetchSize,
View Full Code Here

  }

  @Override
  public Query getNamedQuery(String queryName) throws MappingException {
    errorIfClosed();
    NamedQueryDefinition nqd = factory.getNamedQuery( queryName );
    final Query query;
    if ( nqd != null ) {
      String queryString = nqd.getQueryString();
      query = new QueryImpl(
          queryString,
              nqd.getFlushMode(),
              this,
              getHQLQueryPlan( queryString, false ).getParameterMetadata()
      );
      query.setComment( "named HQL query " + queryName );
    }
View Full Code Here

    Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
    String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
    Attribute cmAtt = queryElem.attribute( "comment" );
    String comment = cmAtt == null ? null : cmAtt.getValue();

    NamedQueryDefinition namedQuery = new NamedQueryDefinition(
        query,
        cacheable,
        region,
        timeout,
        fetchSize,
View Full Code Here

      throw new AnnotationException( "A named query must have a name when used in class or package level" );
    }
    //EJBQL Query
    QueryHint[] hints = queryAnn.hints();
    String queryName = queryAnn.query();
    NamedQueryDefinition query = new NamedQueryDefinition(
        queryName,
        getBoolean( queryName, "org.hibernate.cacheable", hints ),
        getString( queryName, "org.hibernate.cacheRegion", hints ),
        getInteger( queryName, "org.hibernate.timeout", hints ),
        getInteger( queryName, "org.hibernate.fetchSize", hints ),
View Full Code Here

    }

    FlushMode flushMode;
    flushMode = getFlushMode( queryAnn.flushMode() );

    NamedQueryDefinition query = new NamedQueryDefinition(
        queryAnn.query(),
        queryAnn.cacheable(),
        BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
        queryAnn.timeout() < 0 ? null : queryAnn.timeout(),
        queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(),
View Full Code Here

    Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
    String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
    Attribute cmAtt = queryElem.attribute( "comment" );
    String comment = cmAtt == null ? null : cmAtt.getValue();

    NamedQueryDefinition namedQuery = new NamedQueryDefinition(
        query,
        cacheable,
        region,
        timeout,
        fetchSize,
View Full Code Here

    log.debug("Checking " + namedQueries.size() + " named HQL queries");
    Iterator itr = namedQueries.entrySet().iterator();
    while ( itr.hasNext() ) {
      final Map.Entry entry = ( Map.Entry ) itr.next();
      final String queryName = ( String ) entry.getKey();
      final NamedQueryDefinition qd = ( NamedQueryDefinition ) entry.getValue();
      // this will throw an error if there's something wrong.
      try {
        log.debug("Checking named query: " + queryName);
        //TODO: BUG! this currently fails for named queries for non-POJO entities
        queryPlanCache.getHQLQueryPlan( qd.getQueryString(), false, CollectionHelper.EMPTY_MAP );
      }
      catch ( QueryException e ) {
        errors.put( queryName, e );
      }
      catch ( MappingException e ) {
        errors.put( queryName, e );
      }
    }

    log.debug("Checking " + namedSqlQueries.size() + " named SQL queries");
    itr = namedSqlQueries.entrySet().iterator();
    while ( itr.hasNext() ) {
      final Map.Entry entry = ( Map.Entry ) itr.next();
      final String queryName = ( String ) entry.getKey();
      final NamedSQLQueryDefinition qd = ( NamedSQLQueryDefinition ) entry.getValue();
      // this will throw an error if there's something wrong.
      try {
        log.debug("Checking named SQL query: " + queryName);
        // TODO : would be really nice to cache the spec on the query-def so as to not have to re-calc the hash;
        // currently not doable though because of the resultset-ref stuff...
        NativeSQLQuerySpecification spec;
        if ( qd.getResultSetRef() != null ) {
          ResultSetMappingDefinition definition = ( ResultSetMappingDefinition ) sqlResultSetMappings.get( qd.getResultSetRef() );
          if ( definition == null ) {
            throw new MappingException( "Unable to find resultset-ref definition: " + qd.getResultSetRef() );
          }
          spec = new NativeSQLQuerySpecification(
              qd.getQueryString(),
                  definition.getQueryReturns(),
                  qd.getQuerySpaces()
          );
        }
        else {
          spec =  new NativeSQLQuerySpecification(
              qd.getQueryString(),
                  qd.getQueryReturns(),
                  qd.getQuerySpaces()
          );
        }
        queryPlanCache.getNativeSQLQueryPlan( spec );
      }
      catch ( QueryException e ) {
View Full Code Here

      throw new AnnotationException( "A named query must have a name when used in class or package level" );
    }
    //EJBQL Query
    QueryHint[] hints = queryAnn.hints();
    String queryName = queryAnn.query();
    NamedQueryDefinition query = new NamedQueryDefinition(
        queryName,
        getBoolean( queryName, "org.hibernate.cacheable", hints ),
        getString( queryName, "org.hibernate.cacheRegion", hints ),
        getInteger( queryName, "org.hibernate.timeout", hints ),
        getInteger( queryName, "org.hibernate.fetchSize", hints ),
View Full Code Here

TOP

Related Classes of org.hibernate.engine.NamedQueryDefinition

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.