Package org.hibernate

Examples of org.hibernate.QueryException


  QueryableCollection getCollectionPersister(String role) throws QueryException {
    try {
      return ( QueryableCollection ) getFactory().getCollectionPersister( role );
    }
    catch ( ClassCastException cce ) {
      throw new QueryException( "collection role is not queryable: " + role );
    }
    catch ( Exception e ) {
      throw new QueryException( "collection role not found: " + role );
    }
  }
View Full Code Here


  }

  public int[] getNamedParameterLocs(String name) throws QueryException {
    Object o = namedParameters.get( name );
    if ( o == null ) {
      QueryException qe = new QueryException( ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name );
      qe.setQueryString( queryString );
      throw qe;
    }
    if ( o instanceof Integer ) {
      return new int[]{ ( ( Integer ) o ).intValue() };
    }
View Full Code Here

      throws QueryException {
    //q.addCollection(collectionName, collectionRole);
    QueryableCollection persister = getCollectionPersister( collectionRole );
    Type collectionElementType = persister.getElementType();
    if ( !collectionElementType.isEntityType() ) {
      throw new QueryException( "collection of values in filter: " + elementName );
    }

    String[] keyColumnNames = persister.getKeyColumnNames();
    //if (keyColumnNames.length!=1) throw new QueryException("composite-key collection in filter: " + collectionRole);

    String collectionName;
    JoinSequence join = new JoinSequence( getFactory() );
    collectionName = persister.isOneToMany() ?
        elementName :
        createNameForCollection( collectionRole );
    join.setRoot( persister, collectionName );
    if ( !persister.isOneToMany() ) {
      //many-to-many
      addCollection( collectionName, collectionRole );
      try {
        join.addJoin( ( AssociationType ) persister.getElementType(),
            elementName,
            JoinFragment.INNER_JOIN,
            persister.getElementColumnNames(collectionName) );
      }
      catch ( MappingException me ) {
        throw new QueryException( me );
      }
    }
    join.addCondition( collectionName, keyColumnNames, " = ?" );
    //if ( persister.hasWhere() ) join.addCondition( persister.getSQLWhereString(collectionName) );
    EntityType elemType = ( EntityType ) collectionElementType;
View Full Code Here

        Object[] row = ( Object[] ) results.get( i );
        try {
          results.set( i, holderConstructor.newInstance( row ) );
        }
        catch ( Exception e ) {
          throw new QueryException( "could not instantiate: " + holderClass, e );
        }
      }
    }
    return results;
  }
View Full Code Here

    }
    return type;
  }

  protected final QueryException propertyException(String propertyName) throws QueryException {
    return new QueryException( "could not resolve property: " + propertyName + " of: " + getEntityName() );
  }
View Full Code Here

    return true;
  }

  public String render(List args, SessionFactoryImplementor factory) throws QueryException {
    if ( args.size() != 2 && args.size() != 3 ) {
      throw new QueryException( "convert() requires two or three arguments" );
    }
    String type = ( String ) args.get( 1 );

    if ( args.size() == 2 ) {
      return "{fn convert(" + args.get( 0 ) + " , " + type + ")}";
View Full Code Here

  }

  public SQLQuery addJoin(String alias, String path, LockMode lockMode) {
    int loc = path.indexOf('.');
    if ( loc < 0 ) {
      throw new QueryException( "not a property path: " + path );
    }
    String ownerAlias = path.substring(0, loc);
    String role = path.substring(loc+1);
    queryReturns.add( new NativeSQLQueryJoinReturn(alias, ownerAlias, role, CollectionHelper.EMPTY_MAP, lockMode) );
    return this;
View Full Code Here

      // we do not actually propogate ANTLRExceptions as a cause, so
      // log it here for diagnostic purposes
      if ( log.isTraceEnabled() ) {
        log.trace( "converted antlr.ANTLRException", e );
      }
      throw new QueryException( e.getMessage(), hql );
    }

    this.enabledFilters = null; //only needed during compilation phase...
  }
View Full Code Here

    }
    else if ( walker.getStatementType() == HqlSqlTokenTypes.INSERT ) {
      return new BasicExecutor( walker, ( ( InsertStatement ) statement ).getIntoClause().getQueryable() );
    }
    else {
      throw new QueryException( "Unexpected statement type" );
    }
  }
View Full Code Here

    if ( getErrorCount() > 0 ) {
      if ( recognitionExceptions.size() > 0 ) {
        throw QuerySyntaxException.convert( ( RecognitionException ) recognitionExceptions.get( 0 ) );
      }
      else {
        throw new QueryException( getErrorString() );
      }
    }
    else {
      // all clear
      if ( log.isDebugEnabled() ) {
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.