Package org.hibernate

Examples of org.hibernate.QueryException


    return list( session, queryParameters, queryTranslator.getQuerySpaces(), queryReturnTypes );
  }

  private void checkQuery(QueryParameters queryParameters) {
    if ( hasSelectNew() && queryParameters.getResultTransformer() != null ) {
      throw new QueryException( "ResultTransformer is not allowed for 'select new' queries." );
    }
  }
View Full Code Here


    try {

      final PreparedStatement st = prepareQueryStatement( queryParameters, false, session );

      if(queryParameters.isCallable()) {
        throw new QueryException("iterate() not supported for callable statements");
      }
      final ResultSet rs = getResultSet(st, queryParameters.hasAutoDiscoverScalarTypes(), false, queryParameters.getRowSelection(), session);
      final Iterator result = new IteratorImpl(
          rs,
              st,
View Full Code Here

      getStringBuffer().append( comma );
    }
  }

    public static void panic() {
    throw new QueryException( "TreeWalker: panic" );
  }
View Full Code Here

    while ( iter.hasNext() ) {
      Criteria subcriteria = ( Criteria ) iter.next();
      if ( subcriteria.getAlias() != null ) {
        Object old = aliasCriteriaMap.put( subcriteria.getAlias(), subcriteria );
        if ( old != null ) {
          throw new QueryException( "duplicate alias: " + subcriteria.getAlias() );
        }
      }
    }
  }
View Full Code Here

    while ( iter.hasNext() ) {
      CriteriaImpl.Subcriteria crit = ( CriteriaImpl.Subcriteria ) iter.next();
      String wholeAssociationPath = getWholeAssociationPath( crit );
      Object old = associationPathCriteriaMap.put( wholeAssociationPath, crit );
      if ( old != null ) {
        throw new QueryException( "duplicate association path: " + wholeAssociationPath );
      }
      int joinType = crit.getJoinType();
      old = associationPathJoinTypesMap.put( wholeAssociationPath, new Integer( joinType ) );
      if ( old != null ) {
        // TODO : not so sure this is needed...
        throw new QueryException( "duplicate association path: " + wholeAssociationPath );
      }
    }
  }
View Full Code Here

      }
      else if ( type.isComponentType() ) {
        componentPath += '.';
      }
      else {
        throw new QueryException( "not an association: " + componentPath );
      }
    }
    return persister.getEntityName();
  }
View Full Code Here

  }

  public String getColumn(Criteria criteria, String propertyName) {
    String[] cols = getColumns( propertyName, criteria );
    if ( cols.length != 1 ) {
      throw new QueryException( "property does not map to a single column: " + propertyName );
    }
    return cols[0];
  }
View Full Code Here

      }
    }
    else {
      if ( projectionTypes.length != 1 ) {
        //should never happen, i think
        throw new QueryException( "not a single-length projection: " + propertyName );
      }
      return projectionTypes[0];
    }
  }
View Full Code Here

        if ( type instanceof NullableType ) {
          NullableType nullableType = ( NullableType ) type;
          value = nullableType.fromStringValue( stringValue );
        }
        else {
          throw new QueryException( "Unsupported discriminator type " + type );
        }
        return new TypedValue(
            type,
                value,
                EntityMode.POJO
View Full Code Here

      throw new SemanticException( "The [] operator cannot be applied to type " + type.toString() );
    }
    String collectionRole = ( ( CollectionType ) type ).getRole();
    QueryableCollection queryableCollection = sessionFactoryHelper.requireQueryableCollection( collectionRole );
    if ( !queryableCollection.hasIndex() ) {
      throw new QueryException( "unindexed fromElement before []: " + collectionNode.getPath() );
    }

    // Generate the inner join -- The elements need to be joined to the collection they are in.
    FromElement fromElement = collectionNode.getFromElement();
    String elementTable = fromElement.getTableAlias();
    FromClause fromClause = fromElement.getFromClause();
    String path = collectionNode.getPath();

    FromElement elem = fromClause.findCollectionJoin( path );
    if ( elem == null ) {
      FromElementFactory factory = new FromElementFactory( fromClause, fromElement, path );
      elem = factory.createCollectionElementsJoin( queryableCollection, elementTable );
      if ( log.isDebugEnabled() ) {
        log.debug( "No FROM element found for the elements of collection join path " + path
            + ", created " + elem );
      }
    }
    else {
      if ( log.isDebugEnabled() ) {
        log.debug( "FROM element found for collection join path " + path );
      }
    }

    // The 'from element' that represents the elements of the collection.
    setFromElement( fromElement );

    // Add the condition to the join sequence that qualifies the indexed element.
    AST selector = collectionNode.getNextSibling();
    if ( selector == null ) {
      throw new QueryException( "No index value!" );
    }

    // Sometimes use the element table alias, sometimes use the... umm... collection table alias (many to many)
    String collectionTableAlias = elementTable;
    if ( elem.getCollectionTableAlias() != null ) {
      collectionTableAlias = elem.getCollectionTableAlias();
    }

    // TODO: get SQL rendering out of here, create an AST for the join expressions.
    // Use the SQL generator grammar to generate the SQL text for the index expression.
    JoinSequence joinSequence = fromElement.getJoinSequence();
    String[] indexCols = queryableCollection.getIndexColumnNames();
    if ( indexCols.length != 1 ) {
      throw new QueryException( "composite-index appears in []: " + collectionNode.getPath() );
    }
    SqlGenerator gen = new SqlGenerator( getSessionFactoryHelper().getFactory() );
    try {
      gen.simpleExpr( selector ); //TODO: used to be exprNoParens! was this needed?
    }
    catch ( RecognitionException e ) {
      throw new QueryException( e.getMessage(), e );
    }
    String selectorExpression = gen.getSQL();
    joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression );
    List paramSpecs = gen.getCollectedParameters();
    if ( paramSpecs != null ) {
View Full Code Here

TOP

Related Classes of org.hibernate.QueryException

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.