Examples of EOAdaptorContext


Examples of com.webobjects.eoaccess.EOAdaptorContext

    }

    callModelProcessorMethodIfExists("processModel", new Object[] { _model, _entities, flags });

    EODatabaseContext dbc = EODatabaseContext.Factory.newDatabaseContextForDatabase(EODatabase.Factory.newDatabaseForModel(_model));
    EOAdaptorContext ac = dbc.adaptorContext();
    EOSynchronizationFactory sf = ((JDBCAdaptor) ac.adaptor()).plugIn().synchronizationFactory();

    NSMutableArray beforeOpenChannels = new NSMutableArray();
    Enumeration beforeChannelsEnum = ac.channels().objectEnumerator();
    while (beforeChannelsEnum.hasMoreElements()) {
      EOAdaptorChannel channel = (EOAdaptorChannel) beforeChannelsEnum.nextElement();
      if (channel.isOpen()) {
        beforeOpenChannels.addObject(channel);
      }
    }

    StringBuffer sqlBuffer = new StringBuffer();
    fixDuplicateSingleTableInheritanceDropStatements(sf, flags, sqlBuffer);

    try {
      String sql = sf.schemaCreationScriptForEntities(_entities, flags);
      sql = sql.replaceAll("CREATE TABLE ([^\\s(]+)\\(", "CREATE TABLE $1 (");
      sqlBuffer.append(sql);

      callModelProcessorMethodIfExists("processSQL", new Object[] { sqlBuffer, _model, _entities, flags });
    } finally {
      Enumeration afterChannelsEnum = ac.channels().objectEnumerator();
      while (afterChannelsEnum.hasMoreElements()) {
        EOAdaptorChannel channel = (EOAdaptorChannel) afterChannelsEnum.nextElement();
        if (channel.isOpen() && !beforeOpenChannels.containsObject(channel)) {
          channel.closeChannel();
        }
View Full Code Here

Examples of com.webobjects.eoaccess.EOAdaptorContext

  }

  public void executeSQL(String sql) throws SQLException {
    fixClassPath();
    EODatabaseContext databaseContext = EODatabaseContext.Factory.newDatabaseContextForDatabase(EODatabase.Factory.newDatabaseForModel(_model));
    EOAdaptorContext adaptorContext = databaseContext.adaptorContext();

    NSMutableArray beforeOpenChannels = new NSMutableArray();
    Enumeration beforeChannelsEnum = adaptorContext.channels().objectEnumerator();
    while (beforeChannelsEnum.hasMoreElements()) {
      EOAdaptorChannel channel = (EOAdaptorChannel) beforeChannelsEnum.nextElement();
      if (channel.isOpen()) {
        beforeOpenChannels.addObject(channel);
      }
    }
    try {
      EODatabaseChannel databaseChannel = databaseContext.availableChannel();
      EOAdaptorChannel adaptorChannel = databaseChannel.adaptorChannel();
      boolean channelOpen = adaptorChannel.isOpen();
      if (!channelOpen) {
        adaptorChannel.openChannel();
      }
      try {
        JDBCContext jdbccontext = (JDBCContext) adaptorChannel.adaptorContext();
        try {
          jdbccontext.beginTransaction();
          Connection conn = jdbccontext.connection();
          Statement stmt = conn.createStatement();
          stmt.executeUpdate(sql);
          conn.commit();
        } catch (SQLException sqlexception) {
          sqlexception.printStackTrace(System.out);
          jdbccontext.rollbackTransaction();
          throw sqlexception;
        }
      } finally {
        if (!channelOpen) {
          adaptorChannel.closeChannel();
        }
      }
    } finally {
      Enumeration afterChannelsEnum = adaptorContext.channels().objectEnumerator();
      while (afterChannelsEnum.hasMoreElements()) {
        EOAdaptorChannel channel = (EOAdaptorChannel) afterChannelsEnum.nextElement();
        if (channel.isOpen() && !beforeOpenChannels.containsObject(channel)) {
          channel.closeChannel();
        }
View Full Code Here

Examples of com.webobjects.eoaccess.EOAdaptorContext

    }
  }

  public Map externalTypes() {
    EODatabaseContext dbc = EODatabaseContext.Factory.newDatabaseContextForDatabase(EODatabase.Factory.newDatabaseForModel(_model));
    EOAdaptorContext ac = dbc.adaptorContext();
    NSDictionary jdbc2Info = ((JDBCAdaptor) ac.adaptor()).plugIn().jdbcInfo();
    return (Map) EOFSQLUtils56.toJavaCollections(jdbc2Info);
  }
View Full Code Here

Examples of com.webobjects.eoaccess.EOAdaptorContext

    }

    callModelProcessorMethodIfExists("processModel", new Object[] { _model, _entities, flags });

    EODatabaseContext dbc = new EODatabaseContext(new EODatabase(_model));
    EOAdaptorContext ac = dbc.adaptorContext();
    EOSynchronizationFactory sf = ((JDBCAdaptor) ac.adaptor()).plugIn().synchronizationFactory();

    NSMutableArray beforeOpenChannels = new NSMutableArray();
    Enumeration beforeChannelsEnum = ac.channels().objectEnumerator();
    while (beforeChannelsEnum.hasMoreElements()) {
      EOAdaptorChannel channel = (EOAdaptorChannel) beforeChannelsEnum.nextElement();
      if (channel.isOpen()) {
        beforeOpenChannels.addObject(channel);
      }
    }

    StringBuffer sqlBuffer = new StringBuffer();
    fixDuplicateSingleTableInheritanceDropStatements(sf, flags, sqlBuffer);

    try {
      String sql = sf.schemaCreationScriptForEntities(_entities, flags);
      sql = sql.replaceAll("CREATE TABLE ([^\\s(]+)\\(", "CREATE TABLE $1 (");
      sqlBuffer.append(sql);

      callModelProcessorMethodIfExists("processSQL", new Object[] { sqlBuffer, _model, _entities, flags });
    } finally {
      Enumeration afterChannelsEnum = ac.channels().objectEnumerator();
      while (afterChannelsEnum.hasMoreElements()) {
        EOAdaptorChannel channel = (EOAdaptorChannel) afterChannelsEnum.nextElement();
        if (channel.isOpen() && !beforeOpenChannels.containsObject(channel)) {
          channel.closeChannel();
        }
View Full Code Here

Examples of com.webobjects.eoaccess.EOAdaptorContext

  }

  public void executeSQL(String sql) throws SQLException {
    fixClassPath();
    EODatabaseContext databaseContext = new EODatabaseContext(new EODatabase(_model));
    EOAdaptorContext adaptorContext = databaseContext.adaptorContext();

    NSMutableArray beforeOpenChannels = new NSMutableArray();
    Enumeration beforeChannelsEnum = adaptorContext.channels().objectEnumerator();
    while (beforeChannelsEnum.hasMoreElements()) {
      EOAdaptorChannel channel = (EOAdaptorChannel) beforeChannelsEnum.nextElement();
      if (channel.isOpen()) {
        beforeOpenChannels.addObject(channel);
      }
    }
    try {
      EODatabaseChannel databaseChannel = databaseContext.availableChannel();
      EOAdaptorChannel adaptorChannel = databaseChannel.adaptorChannel();
      boolean channelOpen = adaptorChannel.isOpen();
      if (!channelOpen) {
        adaptorChannel.openChannel();
      }
      try {
        JDBCContext jdbccontext = (JDBCContext) adaptorChannel.adaptorContext();
        try {
          jdbccontext.beginTransaction();
          Connection conn = jdbccontext.connection();
          Statement stmt = conn.createStatement();
          stmt.executeUpdate(sql);
          conn.commit();
        } catch (SQLException sqlexception) {
          sqlexception.printStackTrace(System.out);
          jdbccontext.rollbackTransaction();
          throw sqlexception;
        }
      } finally {
        if (!channelOpen) {
          adaptorChannel.closeChannel();
        }
      }
    } finally {
      Enumeration afterChannelsEnum = adaptorContext.channels().objectEnumerator();
      while (afterChannelsEnum.hasMoreElements()) {
        EOAdaptorChannel channel = (EOAdaptorChannel) afterChannelsEnum.nextElement();
        if (channel.isOpen() && !beforeOpenChannels.containsObject(channel)) {
          channel.closeChannel();
        }
View Full Code Here

Examples of com.webobjects.eoaccess.EOAdaptorContext

    }
  }

  public Map externalTypes() {
    EODatabaseContext dbc = new EODatabaseContext(new EODatabase(_model));
    EOAdaptorContext ac = dbc.adaptorContext();
    NSDictionary jdbc2Info = ((JDBCAdaptor) ac.adaptor()).plugIn().jdbcInfo();
    return (Map) EOFSQLUtils53.toJavaCollections(jdbc2Info);
  }
View Full Code Here

Examples of com.webobjects.eoaccess.EOAdaptorContext

    return context;
  }

  @Override
  public EOAdaptorContext createAdaptorContext() {
    EOAdaptorContext context;
    if (_cachedContext != null) {
      context = _cachedContext;
      _cachedContext = null;
    }
    else {
View Full Code Here

Examples of com.webobjects.eoaccess.EOAdaptorContext

    sql.append(')');

    boolean pksGenerated = false;
    EOSQLExpression eosqlexpression = expressionFactory().expressionForString(sql.toString());
    EOAdaptorContext adaptorContext = jdbcchannel.adaptorContext();
    adaptorContext.transactionDidBegin();
    jdbcchannel.evaluateExpression(eosqlexpression);
    if (jdbcchannel._errorEvaluateExpression()) {
      adaptorContext.transactionDidRollback();
      jdbcchannel._setErrorEvaluateExpression(false);
    }
    else {
      jdbcchannel.setAttributesToFetch(attributesToFetch);
      NSMutableDictionary<String, Object> row = jdbcchannel.fetchRow();
      jdbcchannel.cancelFetch();
      adaptorContext.transactionDidCommit();
      if (row != null && row.count() > 0) {
        NSArray pkValues = row.allValues();
        if (pkValues.count() == keyBatchSize) {
          Enumeration keysEnum = pkValues.objectEnumerator();
          while (keysEnum.hasMoreElements()) {
View Full Code Here

Examples of com.webobjects.eoaccess.EOAdaptorContext

   * @return the number of rows updated
   * @throws SQLException
   *             if there is a problem
   */
  public static int executeUpdateScript(EOAdaptorChannel channel, NSArray<String> sqlStatements, boolean ignoreFailures) throws SQLException {
    EOAdaptorContext adaptorContext = channel.adaptorContext();
    // MS: Hack to support memory migrations
    if (!(adaptorContext instanceof JDBCContext)) {
      return 0;
    }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.