Examples of EODatabaseContext


Examples of com.webobjects.eoaccess.EODatabaseContext

    }

    public void createTables(EOEditingContext ec, String modelName) throws SQLException {
        // AK: FIXME we should try with the DROP options enabled and re-try with the options disabled
        // so we catch the case when we
        EODatabaseContext databaseContext = EOUtilities.databaseContextForModelNamed(ec, modelName);
        ERXSQLHelper helper = ERXSQLHelper.newSQLHelper(databaseContext);
        String sql = helper.createSchemaSQLForEntitiesInModelWithName(null, modelName);
        NSArray sqls = helper.splitSQLStatements(sql);
        EOAdaptorChannel channel = databaseContext.availableChannel().adaptorChannel();
        ERXJDBCUtilities.executeUpdateScript(channel, sql);
    }
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

        EOObjectStore os = eo.editingContext().rootObjectStore();
        if (os instanceof EOObjectStoreCoordinator) {
            EOObjectStoreCoordinator osc = (EOObjectStoreCoordinator)os;
            EOCooperatingObjectStore cos = osc.objectStoreForObject(eo);
            if (cos instanceof EODatabaseContext) {
                EODatabaseContext dbctx = (EODatabaseContext)cos;
                EOAdaptor adaptor = dbctx.database().adaptor();
                return ERXJDBCConnectionBroker.connectionBrokerForAdaptor(adaptor);
            }
        }
        throw new IllegalStateException("No connection broker found for EC");
    }
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

            if (log.isDebugEnabled()) {
              log.debug("Batch fetching '" + path + "' relationship on " + sourceObjects);
            }

            EODatabaseContext dbContext = ERXEOAccessUtilities.databaseContextForObject(eo);
            dbContext.lock();
            try {
              ERXEOAccessUtilities.batchFetchRelationship(dbContext, relationship, sourceObjects, ec, skipFaultedSourceObjects);
            }
            finally {
              dbContext.unlock();
            }
        }
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

    // proof way that would be nice to get the model
    // Note you can't use:
    // EOAdaptor.adaptorWithModel(e.entity().model()).expressionFactory();
    // as this creates a
    //
    EODatabaseContext context = EODatabaseContext.registeredDatabaseContextForModel(entity.model(), EOObjectStoreCoordinator.defaultCoordinator());
    EOSQLExpressionFactory factory = context.database().adaptor().expressionFactory();

    NSArray subAttributes = destinationAttName != null ? new NSArray(entity.attributeNamed(destinationAttName)) : entity.primaryKeyAttributes();

    EOSQLExpression subExpression = factory.expressionForEntity(entity);
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

            String destEntityForeignKey = "." + expression.sqlStringForSchemaObjectName(parentChildJoin.destinationAttribute().columnName());
           
            EOQualifier qual = EOQualifierSQLGeneration.Support._schemaBasedQualifierWithRootEntity(subqualifier, destEntity);
            EOFetchSpecification fetchSpecification = new EOFetchSpecification(destEntity.name(), qual, null, false, true, null);

            EODatabaseContext context = EODatabaseContext.registeredDatabaseContextForModel(destEntity.model(), EOObjectStoreCoordinator.defaultCoordinator());
            EOSQLExpressionFactory factory = context.database().adaptor().expressionFactory();

            EOSQLExpression subExpression = factory.expressionForEntity(destEntity);
            subExpression.setUseAliases(true);
            subExpression.prepareSelectExpressionWithAttributes(destEntity.primaryKeyAttributes(), false, fetchSpecification);
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

   * @param model
   * @param coordinator
   * @return the database context for the given model
   */
  private EODatabaseContext databaseContextForModel(EOModel model, EOObjectStoreCoordinator coordinator) {
    EODatabaseContext dbc = null;
    NSArray objectStores = coordinator.cooperatingObjectStores();
    int i = 0;
    for (int c = objectStores.count(); i < c; i++) {
      Object objectStore = objectStores.objectAtIndex(i);
      if ((objectStore instanceof EODatabaseContext) && ((EODatabaseContext) objectStore).database().addModelIfCompatible(model)) {
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

  @SuppressWarnings("unchecked")
  public String createSchemaSQLForEntitiesInModelAndOptions(NSArray<EOEntity> entities, EOModel model, NSDictionary optionsCreate) {
    EOEditingContext ec = ERXEC.newEditingContext();
    ec.lock();
    try {
      EODatabaseContext databaseContext = databaseContextForModel(model, (EOObjectStoreCoordinator) ec.rootObjectStore());
      // AK the default implementation loads the shared objects, and when
      // they don't exist, throw an an error
      // which is not very useful for schema generation
      // But you would probably want to exit soon after calling this....
      // EODatabaseContext databaseContext =
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

   * @return the EOSQLExpression which the EOFetchSpecification would use
   */
  public EOSQLExpression sqlExpressionForFetchSpecification(EOEditingContext ec, EOFetchSpecification spec, long start, long end, NSArray<EOAttribute> attributes) {
    EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, spec.entityName());
    EOModel model = entity.model();
    EODatabaseContext dbc = EOUtilities.databaseContextForModelNamed(ec, model.name());
    EOAdaptor adaptor = dbc.adaptorContext().adaptor();
    EOSQLExpressionFactory sqlFactory = adaptor.expressionFactory();
    spec = (EOFetchSpecification) spec.clone();

    EOQualifier qualifier = spec.qualifier();
    if (qualifier != null) {
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

              if (eo != null && !EOFaultHandler.isFault(eo)) {
                result.addObject(eo);
              }
              else {
                NSDictionary row;
                    EODatabaseContext databaseContext = (EODatabaseContext) ((EOObjectStoreCoordinator) ec.rootObjectStore()).objectStoreForGlobalID(g);
                    databaseContext.lock();
                    try {
                  row = databaseContext.snapshotForGlobalID(g, ec.fetchTimestamp());
                    }
                    finally {
                      databaseContext.unlock();
                    }
                if (row == null) {
                  fetch = true;
                }
                else {
View Full Code Here

Examples of com.webobjects.eoaccess.EODatabaseContext

            NSArray objects = (NSArray) objectsByEntity.objectForKey(entityName);
            EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
            for (Enumeration keyPaths = prefetchingKeypaths.objectEnumerator(); keyPaths.hasMoreElements();) {
              String keypath = (String) keyPaths.nextElement();
              EORelationship relationship = entity.relationshipNamed(keypath);
              EODatabaseContext dbc = ERXEOAccessUtilities.databaseContextForEntityNamed((EOObjectStoreCoordinator) ec.rootObjectStore(), entityName);
              dbc.lock();
              try {
                dbc.batchFetchRelationship(relationship, objects, ec);
              } finally {
                dbc.unlock();
              }
            }
          }
        }
      }
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.