Package org.hibernate.engine

Examples of org.hibernate.engine.ResultSetMappingDefinition


    createFetchJoin( alias, path ).setLockMode( lockMode );
    return this;
  }

  public SQLQuery setResultSetMapping(String name) {
    ResultSetMappingDefinition mapping = session.getFactory().getResultSetMapping( name );
    if ( mapping == null ) {
      throw new MappingException( "Unknown SqlResultSetMapping [" + name + "]" );
    }
    NativeSQLQueryReturn[] returns = mapping.getQueryReturns();
    queryReturns.addAll( Arrays.asList( returns ) );
    return this;
  }
View Full Code Here


          callable
      );
      //TODO check there is no actual definition elemnents when a ref is defined
    }
    else {
      ResultSetMappingDefinition definition = buildResultSetMappingDefinition( queryElem, path, mappings );
      namedQuery = new NamedSQLQueryDefinition(
          queryElem.getText(),
          definition.getQueryReturns(),
          synchronizedTables,
          cacheable,
          region,
          timeout,
          fetchSize,
View Full Code Here

          final NativeSQLQueryReturn[] queryReturns;
          if ( queryDefinition.getQueryReturns() != null ) {
            queryReturns = queryDefinition.getQueryReturns();
          }
          else if ( queryDefinition.getResultSetRef() != null ) {
            final ResultSetMappingDefinition rsMapping = factoryImplementor.getResultSetMapping(
                queryDefinition.getResultSetRef()
            );
            queryReturns = rsMapping.getQueryReturns();
          }
          else {
            throw new AssertionFailure( "Unsupported named query model. Please report the bug in Hibernate EntityManager");
          }
          if ( queryReturns.length > 1 ) {
View Full Code Here

        log.debugf( "Checking named SQL query: %s", namedSQLQueryDefinition.getName() );
        // 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 ( namedSQLQueryDefinition.getResultSetRef() != null ) {
          ResultSetMappingDefinition definition = getResultSetMappingDefinition( namedSQLQueryDefinition.getResultSetRef() );
          if ( definition == null ) {
            throw new MappingException( "Unable to find resultset-ref definition: " + namedSQLQueryDefinition.getResultSetRef() );
          }
          spec = new NativeSQLQuerySpecification(
              namedSQLQueryDefinition.getQueryString(),
              definition.getQueryReturns(),
              namedSQLQueryDefinition.getQuerySpaces()
          );
        }
        else {
          spec =  new NativeSQLQuerySpecification(
View Full Code Here

    this.path = path;
    this.mappings = mappings;
  }

  public void doSecondPass(Map persistentClasses) throws MappingException {
    ResultSetMappingDefinition definition = buildResultSetMappingDefinition( element, path, mappings);
    mappings.addResultSetMapping( definition );
  }
View Full Code Here

  protected static ResultSetMappingDefinition buildResultSetMappingDefinition(Element resultSetElem, String path, Mappings mappings) {
    String resultSetName = resultSetElem.attribute( "name" ).getValue();
    if ( path != null ) {
      resultSetName = path + '.' + resultSetName;
    }
    ResultSetMappingDefinition definition = new ResultSetMappingDefinition( resultSetName );

    int cnt = 0;
    Iterator returns = resultSetElem.elementIterator();
    while ( returns.hasNext() ) {
      cnt++;
      Element returnElem = (Element) returns.next();
      String name = returnElem.getName();
      if ( "return-scalar".equals( name ) ) {
        String column = returnElem.attributeValue( "column" );
        String typeFromXML = HbmBinder.getTypeFromXML( returnElem );
        Type type = null;
        if(typeFromXML!=null) {
          type = mappings.getTypeResolver().heuristicType( typeFromXML );
          if ( type == null ) {
            throw new MappingException( "could not determine type " + type );
          }
        }
        definition.addQueryReturn( new NativeSQLQueryScalarReturn( column, type ) );
      }
      else if ( "return".equals( name ) ) {
        definition.addQueryReturn( bindReturn( returnElem, mappings, cnt ) );
      }
      else if ( "return-join".equals( name ) ) {
        definition.addQueryReturn( bindReturnJoin( returnElem, mappings ) );
      }
      else if ( "load-collection".equals( name ) ) {
        definition.addQueryReturn( bindLoadCollection( returnElem, mappings ) );
      }
    }
    return definition;
  }
View Full Code Here

   * @param resultSetMappingNames The names of the result-set-mappings to resolve
   */
  public static void resolveResultSetMappings(ResultSetMappingResolutionContext context, String... resultSetMappingNames) {
    for ( String resultSetMappingName : resultSetMappingNames ) {
      log.tracef( "Starting attempt resolve named result-set-mapping : %s", resultSetMappingName );
      final ResultSetMappingDefinition mapping = context.findResultSetMapping( resultSetMappingName );
      if ( mapping == null ) {
        throw new UnknownSqlResultSetMappingException( "Unknown SqlResultSetMapping [" + resultSetMappingName + "]" );
      }

      log.tracef( "Found result-set-mapping : %s", mapping.traceLoggableFormat() );

      context.addQueryReturns( mapping.getQueryReturns() );

      final SQLQueryReturnProcessor processor =
          new SQLQueryReturnProcessor( mapping.getQueryReturns(), context.getSessionFactory() );
      final SQLQueryReturnProcessor.ResultAliasContext processResult = processor.process();
      context.addQuerySpaces( processResult.collectQuerySpaces() );
    }
  }
View Full Code Here

          final NativeSQLQueryReturn[] queryReturns;
          if ( queryDefinition.getQueryReturns() != null ) {
            queryReturns = queryDefinition.getQueryReturns();
          }
          else if ( queryDefinition.getResultSetRef() != null ) {
            final ResultSetMappingDefinition rsMapping = factoryImplementor.getResultSetMapping(
                queryDefinition.getResultSetRef()
            );
            queryReturns = rsMapping.getQueryReturns();
          }
          else {
            throw new AssertionFailure( "Unsupported named query model. Please report the bug in Hibernate EntityManager");
          }
          if ( queryReturns.length > 1 ) {
View Full Code Here

          final NativeSQLQueryReturn[] queryReturns;
          if ( queryDefinition.getQueryReturns() != null ) {
            queryReturns = queryDefinition.getQueryReturns();
          }
          else if ( queryDefinition.getResultSetRef() != null ) {
            final ResultSetMappingDefinition rsMapping = factoryImplementor.getResultSetMapping(
                queryDefinition.getResultSetRef()
            );
            queryReturns = rsMapping.getQueryReturns();
          }
          else {
            throw new AssertionFailure( "Unsupported named query model. Please report the bug in Hibernate EntityManager");
          }
          if ( queryReturns.length > 1 ) {
View Full Code Here

    this.path = path;
    this.mappings = mappings;
  }

  public void doSecondPass(Map persistentClasses) throws MappingException {
    ResultSetMappingDefinition definition = buildResultSetMappingDefinition( element, path, mappings);
    mappings.addResultSetMapping( definition );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.ResultSetMappingDefinition

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.