Examples of primaryKeyAttributes()


Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

     *         Foreign-Key attributes for the {@code source} subclass of
     *         {@link ERXCopyable}
     */
    public static NSArray<EOAttribute> primaryAndForeignKeyAttributes(ERXEnterpriseObject source) {
      EOEntity entity = Utility.entity(source);
      NSArray<EOAttribute> primaryKeyAttributes = entity.primaryKeyAttributes();
      NSMutableSet<EOAttribute> keyAttributes = new NSMutableSet<EOAttribute>(primaryKeyAttributes);
      NSArray<EORelationship> classRelationships = Utility.classRelationships(entity);
      for (EORelationship relationship : classRelationships) {
        NSArray<EOAttribute> foreignKeyAttributes = relationship.sourceAttributes();
        keyAttributes.addObjectsFromArray(foreignKeyAttributes);
View Full Code Here

Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

        EOEnterpriseObject eo = ec.faultForGlobalID(gid, ec);
        // EOUtilities.databaseContextForModelNamed(ec, eo.entityName()).forgetSnapshotForGlobalID(gid);
        ec.refaultObject(eo);
        // NOTE AK: I think we can just return the object here,
        // as the next time it is accessed the fault will get
        NSArray primaryKeyAttributes = entity.primaryKeyAttributes();
        EOQualifier qualifier = ERXEOAccessUtilities.qualifierFromAttributes(primaryKeyAttributes, dbSnapshot);
        EOFetchSpecification fs = new EOFetchSpecification(entityName, qualifier, null);
        fs.setRefreshesRefetchedObjects(true);
        NSArray objs = ec.objectsWithFetchSpecification(fs);
        eo = null;
View Full Code Here

Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

     */
    public ERXFetchSpecificationBatchIterator(EOFetchSpecification fetchSpecification, NSArray pkeys, EOEditingContext ec, int batchSize) {
        super();

        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, fetchSpecification.entityName());
        NSArray primaryKeyAttributes = entity.primaryKeyAttributes();
        if (primaryKeyAttributes.count() > 1) {
            throw new RuntimeException("ERXFetchSpecificationBatchIterator: Currently only single primary key entities are supported.");
        }

        primaryKeyAttributeName = ((EOAttribute)primaryKeyAttributes.lastObject()).name();
View Full Code Here

Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

            if (editingContext() == null)
                throw new RuntimeException("Attempting to fetch the primary keys for a null editingContext");

            EOEntity entity = EOUtilities.entityNamed(editingContext(), fetchSpecification.entityName());

            if (entity.primaryKeyAttributes().count() > 1)
                throw new RuntimeException("ERXFetchSpecificationBatchIterator: Currently only single primary key entities are supported.");

            EOFetchSpecification pkFetchSpec = ERXEOControlUtilities.primaryKeyFetchSpecificationForEntity(editingContext(),
                                                                                                      fetchSpecification.entityName(),
                                                                                                      fetchSpecification.qualifier(),
View Full Code Here

Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

              pkFetchSpec.setUsesDistinct(false);
            }
            log.debug("Fetching primary keys.");
            NSArray primaryKeyDictionaries = editingContext().objectsWithFetchSpecification(pkFetchSpec);

            String pkAttributeName = entity.primaryKeyAttributes().lastObject().name();
            primaryKeys = (NSArray)primaryKeyDictionaries.valueForKey(pkAttributeName);
            if (performDistinctInMemory) {
              primaryKeys = ERXArrayUtilities.arrayWithoutDuplicates(primaryKeys);
            }
        }
View Full Code Here

Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

    // 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);

    // Arroz: Having this table identifier replacement causes serious
    // problems if you have more than a table being processed in the subquery. Disabling
View Full Code Here

Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

            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);

            for (Enumeration bindEnumeration = subExpression.bindVariableDictionaries().objectEnumerator(); bindEnumeration.hasMoreElements();) {
                expression.addBindVariableDictionary((NSDictionary)bindEnumeration.nextElement());
            }
View Full Code Here

Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

              // (AR) Write the IN clause
                sb.append(srcEntityForeignKey);
                sb.append(" IN ( ");
               
                // (AR) Rewrite first SELECT part of subExprStr
                EOAttribute destPK = destEntity.primaryKeyAttributes().lastObject();
                String destEntityPrimaryKey = expression.sqlStringForAttribute(destPK);
                int indexOfFirstPeriod = destEntityPrimaryKey.indexOf(".");
                destEntityPrimaryKey = destEntityPrimaryKey.substring(indexOfFirstPeriod);
                subExprStr = StringUtils.replaceOnce(
                    subExprStr,
View Full Code Here

Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

     */
    protected boolean isSinglePrimaryKeyAttribute(EOAttribute attribute) {
      if (attribute == null) return false;
      EOEntity entity = (EOEntity)attribute.entity();
      if ( (entity == null) || entity.isAbstractEntity() || (entity.externalName() == null) ) return false;
      NSArray primaryKeyAttributes = entity.primaryKeyAttributes();
      if (primaryKeyAttributes.count() != 1) return false;
      return attribute.name().equals(((EOAttribute)primaryKeyAttributes.lastObject()).name());
    }
   
    public NSArray primaryKeyConstraintStatementsForEntityGroup(NSArray entityGroup) {
View Full Code Here

Examples of com.webobjects.eoaccess.EOEntity.primaryKeyAttributes()

      NSMutableArray primaryKeyConstraintExpressions = new NSMutableArray();
     
      for (Enumeration enumerator = entityGroup.objectEnumerator(); enumerator.hasMoreElements(); ) {
        EOEntity entity = (EOEntity)enumerator.nextElement();
        String tableName = entity.externalName();
        NSArray primaryKeyAttributes = entity.primaryKeyAttributes();
        boolean singlePrimaryKey = primaryKeyAttributes.count() == 1;
        if( (tableName != null) && ( ! "".equals(tableName) ) && (primaryKeyAttributes.count() > 0) ) {
          NSArray expressions = super.primaryKeyConstraintStatementsForEntityGroup(entityGroup);
          if( (expressions != null) && (expressions.count() > 0) ) primaryKeyConstraintExpressions.addObjectsFromArray(expressions);
          for (Enumeration attributeEnumerator = primaryKeyAttributes.objectEnumerator(); attributeEnumerator.hasMoreElements(); ) {
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.