Package org.hibernate.sql

Examples of org.hibernate.sql.Select


  protected String generateSnapshotSelectString() {

    //TODO: should we use SELECT .. FOR UPDATE?

    Select select = new Select( getFactory().getDialect() );

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "get current state " + getEntityName() );
    }

    String[] aliasedIdColumns = StringHelper.qualify( getRootAlias(), getIdentifierColumnNames() );
    String selectClause = StringHelper.join( ", ", aliasedIdColumns ) +
        concretePropertySelectFragment( getRootAlias(), getPropertyUpdateability() );

    String fromClause = fromTableFragment( getRootAlias() ) +
        fromJoinFragment( getRootAlias(), true, false );

    String whereClause = new StringBuffer()
      .append( StringHelper.join( "=? and ",
          aliasedIdColumns ) )
      .append( "=?" )
      .append( whereJoinFragment( getRootAlias(), true, false ) )
      .toString();

    /*if ( isVersioned() ) {
      where.append(" and ")
        .append( getVersionColumnName() )
        .append("=?");
    }*/

    return select.setSelectClause( selectClause )
        .setFromClause( fromClause )
        .setOuterJoins( "", "" )
        .setWhereClause( whereClause )
        .toStatementString();
  }
View Full Code Here


    //now render the select clause
    SelectFragment selectFragment = createSelect( columnNumbers, formulaNumbers );

    //now tie it all together
    Select select = new Select( getFactory().getDialect() );
    select.setSelectClause( selectFragment.toFragmentString().substring( 2 ) );
    select.setFromClause( from );
    select.setWhereClause( where );
    select.setOuterJoins( jf.toFromFragmentString(), jf.toWhereFragmentString() );
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "sequential select " + getEntityName() );
    }
    return select.toStatementString();
  }
View Full Code Here

      naturalIdMarkers[ naturalIdPropertyIndexes[i] ] = true;
    }

    ///////////////////////////////////////////////////////////////////////
    // TODO : look at perhaps caching this...
    Select select = new Select( getFactory().getDialect() );
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "get current natural-id state " + getEntityName() );
    }
    select.setSelectClause( concretePropertySelectFragmentSansLeadingComma( getRootAlias(), naturalIdMarkers ) );
    select.setFromClause( fromTableFragment( getRootAlias() ) + fromJoinFragment( getRootAlias(), true, false ) );

    String[] aliasedIdColumns = StringHelper.qualify( getRootAlias(), getIdentifierColumnNames() );
    String whereClause = new StringBuffer()
      .append( StringHelper.join( "=? and ",
          aliasedIdColumns ) )
      .append( "=?" )
      .append( whereJoinFragment( getRootAlias(), true, false ) )
      .toString();

    String sql = select.setOuterJoins( "", "" )
        .setWhereClause( whereClause )
        .toStatementString();
    ///////////////////////////////////////////////////////////////////////

    Object[] snapshot = new Object[ naturalIdPropertyCount ];
View Full Code Here

  protected String generateUpdateGeneratedValuesSelectString() {
    return generateGeneratedValuesSelectString( getPropertyUpdateGenerationInclusions() );
  }

  private String generateGeneratedValuesSelectString(ValueInclusion[] inclusions) {
    Select select = new Select( getFactory().getDialect() );

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "get generated state " + getEntityName() );
    }

    String[] aliasedIdColumns = StringHelper.qualify( getRootAlias(), getIdentifierColumnNames() );

    // Here we render the select column list based on the properties defined as being generated.
    // For partial component generation, we currently just re-select the whole component
    // rather than trying to handle the individual generated portions.
    String selectClause = concretePropertySelectFragment( getRootAlias(), inclusions );
    selectClause = selectClause.substring( 2 );

    String fromClause = fromTableFragment( getRootAlias() ) +
        fromJoinFragment( getRootAlias(), true, false );

    String whereClause = new StringBuffer()
      .append( StringHelper.join( "=? and ", aliasedIdColumns ) )
      .append( "=?" )
      .append( whereJoinFragment( getRootAlias(), true, false ) )
      .toString();

    return select.setSelectClause( selectClause )
        .setFromClause( fromClause )
        .setOuterJoins( "", "" )
        .setWhereClause( whereClause )
        .toStatementString();
  }
View Full Code Here

  protected String generateSnapshotSelectString() {

    //TODO: should we use SELECT .. FOR UPDATE?

    Select select = new Select( getFactory().getDialect() );

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "get current state " + getEntityName() );
    }

    String[] aliasedIdColumns = StringHelper.qualify( getRootAlias(), getIdentifierColumnNames() );
    String selectClause = StringHelper.join( ", ", aliasedIdColumns ) +
        concretePropertySelectFragment( getRootAlias(), getPropertyUpdateability() );

    String fromClause = fromTableFragment( getRootAlias() ) +
        fromJoinFragment( getRootAlias(), true, false );

    String whereClause = new StringBuffer()
      .append( StringHelper.join( "=? and ",
          aliasedIdColumns ) )
      .append( "=?" )
      .append( whereJoinFragment( getRootAlias(), true, false ) )
      .toString();

    /*if ( isVersioned() ) {
      where.append(" and ")
        .append( getVersionColumnName() )
        .append("=?");
    }*/

    return select.setSelectClause( selectClause )
        .setFromClause( fromClause )
        .setOuterJoins( "", "" )
        .setWhereClause( whereClause )
        .toStatementString();
  }
View Full Code Here

    //now render the select clause
    SelectFragment selectFragment = createSelect( columnNumbers, formulaNumbers );

    //now tie it all together
    Select select = new Select( getFactory().getDialect() );
    select.setSelectClause( selectFragment.toFragmentString().substring( 2 ) );
    select.setFromClause( from );
    select.setWhereClause( where );
    select.setOuterJoins( jf.toFromFragmentString(), jf.toWhereFragmentString() );
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "sequential select " + getEntityName() );
    }
    return select.toStatementString();
  }
View Full Code Here

    }

  }

  protected String generateIdByUniqueKeySelectString(String uniquePropertyName) {
    Select select = new Select( getFactory().getDialect() );

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "resolve id by unique property [" + getEntityName() + "." + uniquePropertyName + "]" );
    }

    final String rooAlias = getRootAlias();

    select.setFromClause( fromTableFragment( rooAlias ) + fromJoinFragment( rooAlias, true, false ) );

    SelectFragment selectFragment = new SelectFragment();
    selectFragment.addColumns( rooAlias, getIdentifierColumnNames(), getIdentifierAliases() );
    select.setSelectClause( selectFragment );

    StringBuilder whereClauseBuffer = new StringBuilder();
    final int uniquePropertyIndex = getSubclassPropertyIndex( uniquePropertyName );
    final String uniquePropertyTableAlias = generateTableAlias(
        rooAlias,
        getSubclassPropertyTableNumber( uniquePropertyIndex )
    );
    String sep = "";
    for ( String columnTemplate : getSubclassPropertyColumnReaderTemplateClosure()[uniquePropertyIndex] ) {
      if ( columnTemplate == null ) {
        continue;
      }
      final String columnReference = StringHelper.replace( columnTemplate, Template.TEMPLATE, uniquePropertyTableAlias );
      whereClauseBuffer.append( sep ).append( columnReference ).append( "=?" );
      sep = " and ";
    }
    for ( String formulaTemplate : getSubclassPropertyFormulaTemplateClosure()[uniquePropertyIndex] ) {
      if ( formulaTemplate == null ) {
        continue;
      }
      final String formulaReference = StringHelper.replace( formulaTemplate, Template.TEMPLATE, uniquePropertyTableAlias );
      whereClauseBuffer.append( sep ).append( formulaReference ).append( "=?" );
      sep = " and ";
    }
    whereClauseBuffer.append( whereJoinFragment( rooAlias, true, false ) );

    select.setWhereClause( whereClauseBuffer.toString() );

    return select.setOuterJoins( "", "" ).toStatementString();
  }
View Full Code Here

  protected String generateUpdateGeneratedValuesSelectString() {
    return generateGeneratedValuesSelectString( getPropertyUpdateGenerationInclusions() );
  }

  private String generateGeneratedValuesSelectString(ValueInclusion[] inclusions) {
    Select select = new Select( getFactory().getDialect() );

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "get generated state " + getEntityName() );
    }

    String[] aliasedIdColumns = StringHelper.qualify( getRootAlias(), getIdentifierColumnNames() );

    // Here we render the select column list based on the properties defined as being generated.
    // For partial component generation, we currently just re-select the whole component
    // rather than trying to handle the individual generated portions.
    String selectClause = concretePropertySelectFragment( getRootAlias(), inclusions );
    selectClause = selectClause.substring( 2 );

    String fromClause = fromTableFragment( getRootAlias() ) +
        fromJoinFragment( getRootAlias(), true, false );

    String whereClause = new StringBuilder()
      .append( StringHelper.join( "=? and ", aliasedIdColumns ) )
      .append( "=?" )
      .append( whereJoinFragment( getRootAlias(), true, false ) )
      .toString();

    return select.setSelectClause( selectClause )
        .setFromClause( fromClause )
        .setOuterJoins( "", "" )
        .setWhereClause( whereClause )
        .toStatementString();
  }
View Full Code Here

  protected String generateSnapshotSelectString() {

    //TODO: should we use SELECT .. FOR UPDATE?

    Select select = new Select( getFactory().getDialect() );

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "get current state " + getEntityName() );
    }

    String[] aliasedIdColumns = StringHelper.qualify( getRootAlias(), getIdentifierColumnNames() );
    String selectClause = StringHelper.join( ", ", aliasedIdColumns ) +
        concretePropertySelectFragment( getRootAlias(), getPropertyUpdateability() );

    String fromClause = fromTableFragment( getRootAlias() ) +
        fromJoinFragment( getRootAlias(), true, false );

    String whereClause = new StringBuilder()
      .append( StringHelper.join( "=? and ",
          aliasedIdColumns ) )
      .append( "=?" )
      .append( whereJoinFragment( getRootAlias(), true, false ) )
      .toString();

    /*if ( isVersioned() ) {
      where.append(" and ")
        .append( getVersionColumnName() )
        .append("=?");
    }*/

    return select.setSelectClause( selectClause )
        .setFromClause( fromClause )
        .setOuterJoins( "", "" )
        .setWhereClause( whereClause )
        .toStatementString();
  }
View Full Code Here

    //now render the select clause
    SelectFragment selectFragment = createSelect( columnNumbers, formulaNumbers );

    //now tie it all together
    Select select = new Select( getFactory().getDialect() );
    select.setSelectClause( selectFragment.toFragmentString().substring( 2 ) );
    select.setFromClause( from );
    select.setWhereClause( where );
    select.setOuterJoins( jf.toFromFragmentString(), jf.toWhereFragmentString() );
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "sequential select " + getEntityName() );
    }
    return select.toStatementString();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.sql.Select

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.