Package org.hibernate

Examples of org.hibernate.QueryException


  public void validateParameters() throws QueryException {
    int types = positionalParameterTypes == null ? 0 : positionalParameterTypes.length;
    int values = positionalParameterValues == null ? 0 : positionalParameterValues.length;
    if ( types != values ) {
      throw new QueryException(
          "Number of positional parameter types:" + types +
              " does not match number of positional parameters: " + values
      );
    }
  }
View Full Code Here


  }
 
  public int[] getNamedParameterLocs(String name) throws QueryException {
    Object loc = namedParameterBindPoints.get( name );
    if ( loc == null ) {
      throw new QueryException(
          "Named parameter does not appear in Query: " + name,
          sql
      );
    }
    if ( loc instanceof Integer ) {
View Full Code Here

      }
      return buf.toString();
    }
    else {
      if (persister==null) {
        throw new QueryException( "not an entity" );
      }
      String fragment = ( ( Queryable ) persister ).identifierSelectFragment( getTableAlias(), getSuffix( size, k ) );
      return trimLeadingCommaAndSpaces( fragment );
    }
  }
View Full Code Here

      LiteralType literalType = ( LiteralType ) type;
      Dialect dialect = factory.getDialect();
      return literalType.objectToSQLString( constantValue, dialect );
    }
    catch ( Throwable t ) {
      throw new QueryException( QueryTranslator.ERROR_CANNOT_FORMAT_LITERAL + constantExpression, t );
    }
  }
View Full Code Here

  public String getRenderText(SessionFactoryImplementor sessionFactory) {
    try {
      return getTypeInternal().objectToSQLString( getValue(), sessionFactory.getDialect() );
    }
    catch( Throwable t ) {
      throw new QueryException( "Unable to render boolean literal value", t );
    }
  }
View Full Code Here

  private String sqlAssignmentString;

  public AssignmentSpecification(AST eq, Queryable persister) {
    if ( eq.getType() != HqlSqlTokenTypes.EQ ) {
      throw new QueryException( "assignment in set-clause not associated with equals" );
    }

    this.eq = eq;
    this.factory = persister.getFactory();
View Full Code Here

        SqlGenerator sqlGenerator = new SqlGenerator( factory );
        sqlGenerator.comparisonExpr( eq, false )// false indicates to not generate parens around the assignment
        sqlAssignmentString = sqlGenerator.getSQL();
      }
      catch( Throwable t ) {
        throw new QueryException( "cannot interpret set-clause assignment" );
      }
    }
    return sqlAssignmentString;
  }
View Full Code Here

    if ( !lhs.isResolved() ) {
      throw new UnsupportedOperationException( "cannot validate assignablity of unresolved node" );
    }

    if ( lhs.getDataType().isCollectionType() ) {
      throw new QueryException( "collections not assignable in update statements" );
    }
    else if ( lhs.getDataType().isComponentType() ) {
      throw new QueryException( "Components currently not assignable in update statements" );
    }
    else if ( lhs.getDataType().isEntityType() ) {
      // currently allowed...
    }

    // TODO : why aren't these the same?
    if ( lhs.getImpliedJoin() != null || lhs.getFromElement().isImplied() ) {
      throw new QueryException( "Implied join paths are not assignable in update statements" );
    }
  }
View Full Code Here

      // apend everything up until the next encountered open brace
      result.append( sqlQuery.substring( curr, left ) );

      if ( ( right = sqlQuery.indexOf( '}', left + 1 ) ) < 0 ) {
        throw new QueryException( "Unmatched braces for alias path", sqlQuery );
      }

      String aliasPath = sqlQuery.substring( left + 1, right );
      int firstDot = aliasPath.indexOf( '.' );
      if ( firstDot == -1 ) {
View Full Code Here

    SQLLoadableCollection collectionPersister = context.getCollectionPersisterByAlias( aliasName );
    String collectionSuffix = context.getCollectionSuffixByAlias( aliasName );

    if ( "*".equals( propertyName ) ) {
      if( !fieldResults.isEmpty() ) {
        throw new QueryException("Using return-propertys together with * syntax is not supported.");
      }
     
      String selectFragment = collectionPersister.selectFragment( aliasName, collectionSuffix );
      aliasesFound++;
      return selectFragment
            + ", "
            + resolveProperties( aliasName, propertyName );
    }
    else if ( "element.*".equals( propertyName ) ) {
      return resolveProperties( aliasName, "*" );
    }
    else {
      String[] columnAliases;

      // Let return-propertys override whatever the persister has for aliases.
      columnAliases = ( String[] ) fieldResults.get(propertyName);
      if ( columnAliases==null ) {
        columnAliases = collectionPersister.getCollectionPropertyColumnAliases( propertyName, collectionSuffix );
      }
     
      if ( columnAliases == null || columnAliases.length == 0 ) {
        throw new QueryException(
            "No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",
            originalQueryString
        );
      }
      if ( columnAliases.length != 1 ) {
        // TODO: better error message since we actually support composites if names are explicitly listed.
        throw new QueryException(
            "SQL queries only support properties mapped to a single column - property [" +
            propertyName + "] is mapped to " + columnAliases.length + " columns.",
            originalQueryString
        );
      }
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.