Package org.hibernate.engine.spi

Examples of org.hibernate.engine.spi.NamedQueryDefinition


    if ( ! name.equals( definition.getName() ) ) {
      definition = definition.makeCopy( name );
    }

    final Map<String, NamedQueryDefinition> copy = CollectionHelper.makeCopy( namedQueryDefinitionMap );
    final NamedQueryDefinition previous = copy.put( name, definition );
    if ( previous != null ) {
      log.debugf(
          "registering named query definition [%s] overriding previously registered definition [%s]",
          name,
          previous
View Full Code Here


    if ( ! name.equals( definition.getName() ) ) {
      definition = definition.makeCopy( name );
    }

    final Map<String, NamedSQLQueryDefinition> copy = CollectionHelper.makeCopy( namedSqlQueryDefinitionMap );
    final NamedQueryDefinition previous = copy.put( name, definition );
    if ( previous != null ) {
      log.debugf(
          "registering named SQL query definition [%s] overriding previously registered definition [%s]",
          name,
          previous
View Full Code Here

        LOG.debugf("Checking %s named HQL queries", namedQueries.size());
    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.debugf("Checking named query: %s", 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 );
      }
    }
    if(LOG.isDebugEnabled())
        LOG.debugf("Checking %s named SQL queries", namedSqlQueries.size());
    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.debugf("Checking named SQL query: %s", 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

    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 NamedQueryDefinitionBuilder().setName( queryName )
        .setQuery( query )
        .setCacheable( cacheable )
        .setCacheRegion( region )
        .setTimeout( timeout )
        .setFetchSize( fetchSize )
        .setFlushMode( FlushMode.interpretExternalSetting( queryElem.attributeValue( "flush-mode" ) ) )
        .setCacheMode( CacheMode.interpretExternalSetting( cacheMode ) )
        .setReadOnly( readOnly )
        .setComment( comment )
        .setParameterTypes( getParameterTypes( queryElem ) )
        .createNamedQueryDefinition();

    mappings.addQuery( namedQuery.getName(), namedQuery );
  }
View Full Code Here

      throw new AnnotationException( "A named query must have a name when used in class or package level" );
    }
    //EJBQL Query
    QueryHintDefinition hints = new QueryHintDefinition( queryAnn.hints() );
    String queryName = queryAnn.query();
    NamedQueryDefinition queryDefinition = new NamedQueryDefinitionBuilder( queryAnn.name() )
        .setLockOptions( hints.determineLockOptions( queryAnn ) )
        .setQuery( queryName )
        .setCacheable( hints.getBoolean( queryName, QueryHints.CACHEABLE ) )
        .setCacheRegion( hints.getString( queryName, QueryHints.CACHE_REGION ) )
        .setTimeout( hints.getTimeout( queryName ) )
        .setFetchSize( hints.getInteger( queryName, QueryHints.FETCH_SIZE ) )
        .setFlushMode( hints.getFlushMode( queryName ) )
        .setCacheMode( hints.getCacheMode( queryName ) )
        .setReadOnly( hints.getBoolean( queryName, QueryHints.READ_ONLY ) )
        .setComment( hints.getString( queryName, QueryHints.COMMENT ) )
        .setParameterTypes( null )
        .createNamedQueryDefinition();

    if ( isDefault ) {
      mappings.addDefaultQuery( queryDefinition.getName(), queryDefinition );
    }
    else {
      mappings.addQuery( queryDefinition.getName(), queryDefinition );
    }
    if ( LOG.isDebugEnabled() ) {
      LOG.debugf( "Binding named query: %s => %s", queryDefinition.getName(), queryDefinition.getQueryString() );
    }
  }
View Full Code Here

      throw new AnnotationException( "A named query must have a name when used in class or package level" );
    }
    FlushMode flushMode;
    flushMode = getFlushMode( queryAnn.flushMode() );

    NamedQueryDefinition query = new NamedQueryDefinitionBuilder().setName( queryAnn.name() )
        .setQuery( queryAnn.query() )
        .setCacheable( queryAnn.cacheable() )
        .setCacheRegion(
            BinderHelper.isEmptyAnnotationValue( queryAnn.cacheRegion() ) ?
                null :
                queryAnn.cacheRegion()
        )
        .setTimeout( queryAnn.timeout() < 0 ? null : queryAnn.timeout() )
        .setFetchSize( queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize() )
        .setFlushMode( flushMode )
        .setCacheMode( getCacheMode( queryAnn.cacheMode() ) )
        .setReadOnly( queryAnn.readOnly() )
        .setComment( BinderHelper.isEmptyAnnotationValue( queryAnn.comment() ) ? null : queryAnn.comment() )
        .setParameterTypes( null )
        .createNamedQueryDefinition();

    mappings.addQuery( query.getName(), query );
    if ( LOG.isDebugEnabled() ) {
      LOG.debugf( "Binding named query: %s => %s", query.getName(), query.getQueryString() );
    }
  }
View Full Code Here

    }
    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.debugf( "Checking named query: %s", queryName );
        //TODO: BUG! this currently fails for named queries for non-POJO entities
        queryPlanCache.getHQLQueryPlan( qd.getQueryString(), false, Collections.EMPTY_MAP );
      }
      catch ( QueryException e ) {
        errors.put( queryName, e );
      }
      catch ( MappingException e ) {
        errors.put( queryName, e );
      }


    }
    if ( LOG.isDebugEnabled() ) {
      LOG.debugf( "Checking %s named SQL queries", namedSqlQueries.size() );
    }
    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.debugf( "Checking named SQL query: %s", 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 = 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

    }
    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 {
        if ( debugEnabled ) {
          LOG.debugf( "Checking named query: %s", queryName );
        }
        //TODO: BUG! this currently fails for named queries for non-POJO entities
        queryPlanCache.getHQLQueryPlan( qd.getQueryString(), false, Collections.EMPTY_MAP );
      }
      catch ( QueryException e ) {
        errors.put( queryName, e );
      }
      catch ( MappingException e ) {
        errors.put( queryName, e );
      }
    }
    if ( debugEnabled ) {
      LOG.debugf( "Checking %s named SQL queries", namedSqlQueries.size() );
    }
    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 {
        if ( debugEnabled ) {
          LOG.debugf( "Checking named SQL query: %s", 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 = 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

    String comment = getString( hints, QueryHints.COMMENT );
    if ( StringHelper.isEmpty( comment ) ) {
      comment = null;
    }
    metadata.addNamedQuery(
        new NamedQueryDefinition(
            name,
            query, getBoolean( hints, QueryHints.CACHEABLE, name ), cacheRegion,
            timeout, fetchSize, getFlushMode( hints, QueryHints.FLUSH_MODE, name ),
            getCacheMode( hints, QueryHints.CACHE_MODE, name ),
            getBoolean( hints, QueryHints.READ_ONLY, name ), comment, null
View Full Code Here

        LOG.debugf("Checking %s named HQL queries", namedQueries.size());
    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.debugf("Checking named query: %s", 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 );
      }
    }
    if(LOG.isDebugEnabled())
        LOG.debugf("Checking %s named SQL queries", namedSqlQueries.size());
    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.debugf("Checking named SQL query: %s", 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

TOP

Related Classes of org.hibernate.engine.spi.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.