Package er.extensions.jdbc

Examples of er.extensions.jdbc.ERXSQLHelper


   * @param defaultValue the default value of this column
   * @return the new ERXMigrationColumn
   * @throws SQLException if the column cannot be created
   */
  public ERXMigrationColumn newStringColumn(String name, boolean allowsNull, String defaultValue) throws SQLException {
    ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(_database.adaptorChannel());
    return newColumn(name, sqlHelper.varcharLargeJDBCType(), sqlHelper.varcharLargeColumnWidth(), 0, 0, allowsNull, null, defaultValue);
  }
View Full Code Here


   * @param columnIndexes the column indexes to unique index on
   * @throws SQLException if the constraint fails
   */
  public void addUniqueIndex(boolean create, String indexName, ERXSQLHelper.ColumnIndex... columnIndexes) throws SQLException {
    if (create) {
      ERXSQLHelper helper = ERXSQLHelper.newSQLHelper(_database.adaptorChannel());
      if(indexName == null) {
        indexName = _defaultIndexName(true, _name, helper.columnNamesFromColumnIndexes(columnIndexes).toArray(new String[] {}));
      }
      String sql = helper.sqlForCreateUniqueIndex(indexName, _name, columnIndexes);
      ERXJDBCUtilities.executeUpdateScript(_database.adaptorChannel(), sql);
    }
    else {
      _indexes.addObject(new ERXMigrationIndex(indexName, true, columnIndexes));
    }
View Full Code Here

   * @param columnIndexes the column indexes to unique index on
   * @throws SQLException if the constraint fails
   */
  public void addIndex(boolean create, String indexName, ERXSQLHelper.ColumnIndex... columnIndexes) throws SQLException {
    if (create) {
      ERXSQLHelper helper = ERXSQLHelper.newSQLHelper(_database.adaptorChannel());
      if (indexName == null) {
        indexName = _defaultIndexName(false, _name, helper.columnNamesFromColumnIndexes(columnIndexes).toArray(new String[] {}));
      }
      String sql = helper.sqlForCreateIndex(indexName, _name, columnIndexes);
      ERXJDBCUtilities.executeUpdateScript(_database.adaptorChannel(), sql);
    }
    else {
      _indexes.addObject(new ERXMigrationIndex(indexName, false, columnIndexes));
    }
View Full Code Here

      EOEditingContext editingContext = newEditingContext();
      editingContext.lock();
      try {
        ERXMigrationAction migrationAction = new ERXMigrationAction(editingContext, migration, modelVersion, migrationLock, _lockOwnerName, postMigrations);
        try {
          ERXSQLHelper helper = ERXSQLHelper.newSQLHelper(model);
          try {
            helper.prepareConnectionForSchemaChange(editingContext, model);
            migrationAction.perform(editingContext, model.name());
          }
          finally {
            helper.restoreConnectionSettingsAfterSchemaChange(editingContext, model);
          }
        }
        catch (ERXMigrationFailedException e) {
          throw e;
        }
View Full Code Here

  }

  @Override
  public String sqlStringForSQLExpression(EOQualifier qualifier, EOSQLExpression expression) {
    ERXFullTextQualifier fullTextQualifier = (ERXFullTextQualifier) qualifier;
    ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(expression);
    return sqlHelper.sqlForFullTextQuery(fullTextQualifier, expression);
  }
View Full Code Here

    entity.addAttribute(nonJdbcAttribute);
      return nonJdbcAttribute;
    }
   
    JDBCAdaptor adaptor = (JDBCAdaptor)_table.database().adaptor();
    ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(adaptor);
    String externalType = sqlHelper.externalTypeForJDBCType(adaptor, _jdbcType);
    if (externalType == null) {
      externalType = "IF_YOU_ARE_SEEING_THIS_SOMETHING_WENT_WRONG_WITH_EXTERNAL_TYPES";
    }
    EOAttribute attribute = adaptor.createAttribute(_name, _name, _jdbcType, externalType, _precision, _scale, _allowsNull ? 1 : 0);
    if (_width > 0) {
      attribute.setWidth(_width);
    }
    if (_defaultValue != null) {
      NSDictionary userInfo = attribute.userInfo();
      NSMutableDictionary mutableUserInfo;
      if (userInfo == null) {
        mutableUserInfo = new NSMutableDictionary();
      }
      else {
        mutableUserInfo = userInfo.mutableClone();
      }
      mutableUserInfo.setObjectForKey(_defaultValue, "default");
      attribute.setUserInfo(mutableUserInfo);
    }

    if (_overrideValueType != null) {
      if (ERXMigrationColumn.NULL_VALUE_TYPE.equals(_overrideValueType)) {
        attribute.setValueType(null);
      }
      else {
        attribute.setValueType(_overrideValueType);
      }
      if (sqlHelper.reassignExternalTypeForValueTypeOverride(attribute)) {
        adaptor.assignExternalTypeForAttribute(attribute);
      }
    }

    if (_overrideExternalType != null) {
View Full Code Here

    try {
      ERXEOAccessUtilities.ChannelAction action = new ERXEOAccessUtilities.ChannelAction() {
        @Override
        protected int doPerform(EOAdaptorChannel channel) {
          try {
            ERXSQLHelper helper = ERXSQLHelper.newSQLHelper(adaptorName);
            String sql = helper.createSchemaSQLForEntitiesInModelAndOptions(model.entities(), model, helper.defaultOptionDictionary(false, true)) ;
            log.debug(sql);
            try {
              ERXJDBCUtilities.executeUpdateScript(channel, sql);
            } catch (Throwable e) {
              log.info("drop failure");
            }
            sql = helper.createSchemaSQLForEntitiesInModelAndOptions(model.entities(), model, helper.defaultOptionDictionary(true, false)) ;
            log.debug(sql);
            ERXJDBCUtilities.executeUpdateScript(channel, sql);
          }
          catch (SQLException e) {
            throw new NSForwardException(e);
View Full Code Here

TOP

Related Classes of er.extensions.jdbc.ERXSQLHelper

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.