Package org.hibernate.sql

Examples of org.hibernate.sql.ConditionFragment


      }
      select.appendRestrictions( in.toFragmentString() );
    }
    else {
      // A COMPOSITE KEY...
      final ConditionFragment keyRestrictionBuilder = new ConditionFragment()
          .setTableAlias( alias )
          .setCondition( keyColumnNames, "?" );
      final String keyRestrictionFragment = keyRestrictionBuilder.toFragmentString();

      StringBuilder restrictions = new StringBuilder();
      if ( batchSize==1 ) {
        // for no batching, use "foo = ? and bar = ?"
        restrictions.append( keyRestrictionFragment );
View Full Code Here


    final String[] collectionKeys = collectionPersister.getKeyColumnNames();
    final String[] ownerKeys = ( (Loadable) factory.getEntityPersister( entityName ) ).getIdentifierColumnNames();

    final String innerSelect = "(select 1 from " + collectionPersister.getTableName() + " where "
        + new ConditionFragment().setTableAlias( sqlAlias ).setCondition( ownerKeys, collectionKeys ).toFragmentString()
        + ")";

    return excludeEmpty()
        ? "exists " + innerSelect
        : "not exists " + innerSelect;
View Full Code Here

      for ( int i=0; i<batchSize; i++ ) in.addValue("?");
      return new StringBuilder( in.toFragmentString() );
    }
    else {
      //a composite key
      ConditionFragment byId = new ConditionFragment()
          .setTableAlias(alias)
          .setCondition( columnNames, "?" );
 
      StringBuilder whereString = new StringBuilder();
      if ( batchSize==1 ) {
        // if no batch, use "foo = ? and bar = ?"
        whereString.append( byId.toFragmentString() );
      }
      else {
        // if a composite key, use "( (foo = ? and bar = ?) or (foo = ? and bar = ?) )" for batching
        whereString.append('('); //TODO: unnecessary for databases with ANSI-style joins
        DisjunctionFragment df = new DisjunctionFragment();
View Full Code Here

    final QueryableCollection cp = (QueryableCollection) criteriaQuery.getFactory().getCollectionPersister( role );

    final String[] fk = cp.getKeyColumnNames();
    final String[] pk = ( (Loadable) cp.getOwnerEntityPersister() ).getIdentifierColumnNames();

    final ConditionFragment subQueryRestriction = new ConditionFragment()
        .setTableAlias( criteriaQuery.getSQLAlias( criteria, propertyName ) )
        .setCondition( pk, fk );

    return String.format(
        "? %s (select count(*) from %s where %s)",
        op,
        cp.getTableName(),
        subQueryRestriction.toFragmentString()
    );
  }
View Full Code Here

        op +
        " (select count(*) from " +
        cp.getTableName() +
        //" collection_ where " +
        " where " +
        new ConditionFragment()
            .setTableAlias( criteriaQuery.getSQLAlias(criteria, propertyName) )
            .setCondition(pk, fk)
            .toFragmentString() +
        ")";
  }
View Full Code Here

      for ( int i=0; i<batchSize; i++ ) in.addValue("?");
      return new StringBuffer( in.toFragmentString() );
    }
    else {
      //a composite key
      ConditionFragment byId = new ConditionFragment()
          .setTableAlias(alias)
          .setCondition( columnNames, "?" );
 
      StringBuffer whereString = new StringBuffer();
      if ( batchSize==1 ) {
        // if no batch, use "foo = ? and bar = ?"
        whereString.append( byId.toFragmentString() );
      }
      else {
        // if a composite key, use "( (foo = ? and bar = ?) or (foo = ? and bar = ?) )" for batching
        whereString.append('('); //TODO: unnecessary for databases with ANSI-style joins
        DisjunctionFragment df = new DisjunctionFragment();
View Full Code Here

        op +
        " (select count(*) from " +
        cp.getTableName() +
        //" collection_ where " +
        " where " +
        new ConditionFragment()
            .setTableAlias( criteriaQuery.getSQLAlias(criteria, propertyName) )
            .setCondition(pk, fk)
            .toFragmentString() +
        ")";
  }
View Full Code Here

    String[] collectionKeys = collectionPersister.getKeyColumnNames();
    String[] ownerKeys = ( ( Loadable ) factory.getEntityPersister( entityName ) ).getIdentifierColumnNames();

    String innerSelect = "(select 1 from " + collectionPersister.getTableName()
            + " where "
            + new ConditionFragment().setTableAlias( sqlAlias ).setCondition( ownerKeys, collectionKeys ).toFragmentString()
            + ")";

    return excludeEmpty()
            ? "exists " + innerSelect
            : "not exists " + innerSelect;
View Full Code Here

      for ( int i=0; i<batchSize; i++ ) in.addValue("?");
      return new StringBuffer( in.toFragmentString() );
    }
    else {
      //a composite key
      ConditionFragment byId = new ConditionFragment()
          .setTableAlias(alias)
          .setCondition( columnNames, "?" );
 
      StringBuffer whereString = new StringBuffer();
      if ( batchSize==1 ) {
        // if no batch, use "foo = ? and bar = ?"
        whereString.append( byId.toFragmentString() );
      }
      else {
        // if a composite key, use "( (foo = ? and bar = ?) or (foo = ? and bar = ?) )" for batching
        whereString.append('('); //TODO: unnecessary for databases with ANSI-style joins
        DisjunctionFragment df = new DisjunctionFragment();
View Full Code Here

    String[] collectionKeys = collectionPersister.getKeyColumnNames();
    String[] ownerKeys = ( ( Loadable ) factory.getEntityPersister( entityName ) ).getIdentifierColumnNames();

    String innerSelect = "(select 1 from " + collectionPersister.getTableName()
            + " where "
            + new ConditionFragment().setTableAlias( sqlAlias ).setCondition( ownerKeys, collectionKeys ).toFragmentString()
            + ")";

    return excludeEmpty()
            ? "exists " + innerSelect
            : "not exists " + innerSelect;
View Full Code Here

TOP

Related Classes of org.hibernate.sql.ConditionFragment

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.