public SimpleSelect addColumns(String[] columns, String[] aliases, boolean[] ignore) { for ( int i = 0; i < ignore.length; i++ ) { if ( !ignore[i] && columns[i] != null ) { addColumn( columns[i], aliases[i] ); } } return this; }
/** * Generate the SQL that selects the version number by id */ protected String generateSelectVersionString() { SimpleSelect select = new SimpleSelect( getFactory().getDialect() ) .setTableName( getVersionedTableName() ); if ( isVersioned() ) { select.addColumn( versionColumnName ); } else { select.addColumns( rootTableKeyColumnNames ); } if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) { select.setComment( "get version " + getEntityName() ); } return select.addCondition( rootTableKeyColumnNames, "=?" ).toStatementString(); }
public SimpleSelect addColumns(String[] columnNames, String[] columnAliases) { for ( int i = 0; i < columnNames.length; i++ ) { if ( columnNames[i] != null ) { addColumn( columnNames[i], columnAliases[i] ); } } return this; }
public SimpleSelect addColumns(String[] columnNames) { for ( String columnName : columnNames ) { if ( columnName != null ) { addColumn( columnName ); } } return this; }
protected String generateSelectSizeString(boolean isIntegerIndexed) { String selectValue = isIntegerIndexed ? "max(" + getIndexColumnNames()[0] + ") + 1" : // lists, arrays "count(" + getElementColumnNames()[0] + ")"; // sets, maps, bags return new SimpleSelect( dialect ) .setTableName( getTableName() ) .addCondition( getKeyColumnNames(), "=?" ) .addWhereToken( sqlWhereString ) .addColumn( selectValue ) .toStatementString(); }
protected String generateDetectRowByElementString() { return new SimpleSelect( dialect ) .setTableName( getTableName() ) .addCondition( getKeyColumnNames(), "=?" ) .addCondition( getElementColumnNames(), "=?" ) .addCondition( elementFormulas, "=?" ) .addWhereToken( sqlWhereString ) .addColumn( "1" ) .toStatementString(); }
protected String generateDetectRowByIndexString() { if ( !hasIndex() ) { return null; } return new SimpleSelect( dialect ) .setTableName( getTableName() ) .addCondition( getKeyColumnNames(), "=?" ) .addCondition( getIndexColumnNames(), "=?" ) .addCondition( indexFormulas, "=?" ) .addWhereToken( sqlWhereString ) .addColumn( "1" ) .toStatementString(); }
SimpleSelect select = new SimpleSelect( getDialect() ) .setTableName( queryableCollection.getTableName() ) .addColumn( "code" ) .addColumn( "transactions_index" ); PreparedStatement preparedStatement = ((SessionImplementor)s).getJdbcCoordinator().getStatementPreparer().prepareStatement( select.toStatementString() ); ResultSet resultSet = ((SessionImplementor)s).getJdbcCoordinator().getResultSetReturn().extract( preparedStatement );
protected String generateLockString(int lockTimeout) { final SessionFactoryImplementor factory = getLockable().getFactory(); final LockOptions lockOptions = new LockOptions( getLockMode() ); lockOptions.setTimeOut( lockTimeout ); final SimpleSelect select = new SimpleSelect( factory.getDialect() ) .setLockOptions( lockOptions ) .setTableName( getLockable().getRootTableName() ) .addColumn( getLockable().getRootTableIdentifierColumnNames()[0] ) .addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" ); if ( getLockable().isVersioned() ) { select.addCondition( getLockable().getVersionColumnName(), "=?" ); } if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) { select.setComment( getLockMode() + " lock " + getLockable().getEntityName() ); } return select.toStatementString(); } }
protected String generateLockString(int timeout) { final SessionFactoryImplementor factory = getLockable().getFactory(); final LockOptions lockOptions = new LockOptions( getLockMode() ); lockOptions.setTimeOut( timeout ); final SimpleSelect select = new SimpleSelect( factory.getDialect() ) .setLockOptions( lockOptions ) .setTableName( getLockable().getRootTableName() ) .addColumn( getLockable().getRootTableIdentifierColumnNames()[0] ) .addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" ); if ( getLockable().isVersioned() ) { select.addCondition( getLockable().getVersionColumnName(), "=?" ); } if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) { select.setComment( getLockMode() + " lock " + getLockable().getEntityName() ); } return select.toStatementString(); } }
protected String generateLockString(int lockTimeout) { final SessionFactoryImplementor factory = getLockable().getFactory(); final LockOptions lockOptions = new LockOptions( getLockMode() ); lockOptions.setTimeOut( lockTimeout ); final SimpleSelect select = new SimpleSelect( factory.getDialect() ) .setLockOptions( lockOptions ) .setTableName( getLockable().getRootTableName() ) .addColumn( getLockable().getRootTableIdentifierColumnNames()[0] ) .addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" ); if ( getLockable().isVersioned() ) { select.addCondition( getLockable().getVersionColumnName(), "=?" ); } if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) { select.setComment( getLockMode() + " lock " + getLockable().getEntityName() ); } return select.toStatementString(); } }
public SimpleSelect addColumns(String[] columnNames) { for ( int i=0; i<columnNames.length; i++ ) { if ( columnNames[i]!=null ) addColumn( columnNames[i] ); } return this; } public SimpleSelect addColumn(String columnName) {
public SimpleSelect addColumns(String[] columnNames) { for ( int i=0; i<columnNames.length; i++ ) { if ( columnNames[i]!=null ) addColumn( columnNames[i] ); } return this; } public SimpleSelect addColumn(String columnName) {
public SimpleSelect addColumns(String[] columnNames, String[] columnAliases) { for ( int i=0; i<columnNames.length; i++ ) { addColumn( columnNames[i], columnAliases[i] ); } return this; }
public SimpleSelect addColumns(String[] columnNames, String[] columnAliases) { for ( int i=0; i<columnNames.length; i++ ) { if ( columnNames[i]!=null ) { addColumn( columnNames[i], columnAliases[i] ); } } return this; }
public SimpleSelect addColumns(String[] columnNames, String[] columnAliases) { for ( int i=0; i<columnNames.length; i++ ) { if ( columnNames[i]!=null ) { addColumn( columnNames[i], columnAliases[i] ); } } return this; }
protected String generateDetectRowByElementString() { return new SimpleSelect( dialect ) .setTableName( getTableName() ) .addCondition( getKeyColumnNames(), "=?" ) .addCondition( getElementColumnNames(), "=?" ) .addCondition( elementFormulas, "=?" ) .addColumn( "1" ) .toStatementString(); }
protected String generateDetectRowByIndexString() { if ( !hasIndex() ) { return null; } return new SimpleSelect( dialect ) .setTableName( getTableName() ) .addCondition( getKeyColumnNames(), "=?" ) .addCondition( getIndexColumnNames(), "=?" ) .addCondition( indexFormulas, "=?" ) .addColumn( "1" ) .toStatementString(); }
protected String generateDetectRowByIndexString() { if ( !hasIndex() ) { return null; } return new SimpleSelect( dialect ) .setTableName( getTableName() ) .addCondition( getKeyColumnNames(), "=?" ) .addCondition( getIndexColumnNames(), "=?" ) .addCondition( indexFormulas, "=?" ) .addColumn( "1" ) .toStatementString(); }