Package com.webobjects.eoaccess

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


    EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName);
    while (entity.parentEntity() != null) {
      entity = entity.parentEntity();
    }
    entityName = entity.name();
    if(entity.primaryKeyAttributeNames().count() != 1) {
      throw new IllegalArgumentException("Can handle only entities with one PK: " + entityName + " has " + entity.primaryKeyAttributeNames());
    }

    Long pk = getNextPkValueForEntity(entityName);
    String pkName = entity.primaryKeyAttributeNames().objectAtIndex(0);
View Full Code Here


    while (entity.parentEntity() != null) {
      entity = entity.parentEntity();
    }
    entityName = entity.name();
    if(entity.primaryKeyAttributeNames().count() != 1) {
      throw new IllegalArgumentException("Can handle only entities with one PK: " + entityName + " has " + entity.primaryKeyAttributeNames());
    }

    Long pk = getNextPkValueForEntity(entityName);
    String pkName = entity.primaryKeyAttributeNames().objectAtIndex(0);
    return new NSDictionary(new Object[] { pk}, new Object[] { pkName});
View Full Code Here

    if(entity.primaryKeyAttributeNames().count() != 1) {
      throw new IllegalArgumentException("Can handle only entities with one PK: " + entityName + " has " + entity.primaryKeyAttributeNames());
    }

    Long pk = getNextPkValueForEntity(entityName);
    String pkName = entity.primaryKeyAttributeNames().objectAtIndex(0);
    return new NSDictionary(new Object[] { pk}, new Object[] { pkName});
  }

  /**
   * returns a new primary key for the specified entity.
View Full Code Here

        expression.setStatement(processedQueryString(query, expression, bindings));

        EOFetchSpecification pkSpec = new EOFetchSpecification( entityName, null, null );
        pkSpec.setRefreshesRefetchedObjects(refreshesCache);
        pkSpec.setFetchesRawRows(true);
        pkSpec.setRawRowKeyPaths(entity.primaryKeyAttributeNames());
        pkSpec.setHints( new NSDictionary( expression, EODatabaseContext.CustomQueryExpressionHintKey ) );

        NSArray pkDicts = ec.objectsWithFetchSpecification(pkSpec);
        NSMutableArray pks = new NSMutableArray();
        String pkAtttributeName = entity.primaryKeyAttributes().lastObject().name();
View Full Code Here

    public EOFetchSpecification primaryKeyFetchSpecificationForEntity(EOEditingContext ec, EOQualifier eoqualifier, NSArray sortOrderings, NSArray additionalKeys) {
        String entityName = entityName();
        EOFetchSpecification fs = new EOFetchSpecification(entityName, eoqualifier, sortOrderings);
        fs.setFetchesRawRows(true);
        EOEntity entity = entity(ec);
        NSMutableArray keys = new NSMutableArray(entity.primaryKeyAttributeNames());
        if(additionalKeys != null) {
            keys.addObjectsFromArray(additionalKeys);
        }
        if(entity.restrictingQualifier() != null) {
            NSArray restrict = entity.restrictingQualifier().allQualifierKeys().allObjects();
View Full Code Here

                                                                      NSArray<EOSortOrdering> sortOrderings,
                                                                      NSArray<String> additionalKeys) {
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
        EOFetchSpecification fs = new EOFetchSpecification(entityName, eoqualifier, sortOrderings);
        fs.setFetchesRawRows(true);
        NSMutableArray<String> keys = new NSMutableArray<String>(entity.primaryKeyAttributeNames());
        if (additionalKeys != null) {
            keys.addObjectsFromArray(additionalKeys);
        }
        fs.setRawRowKeyPaths(keys);
        return fs;
View Full Code Here

            values = (NSDictionary<String, Object>)primaryKeyValue;
        else {
            if (entity.primaryKeyAttributes().count() != 1) {
                throw new IllegalStateException("The entity '" + entity.name() + "' has a compound primary key and cannot be used with a single primary key value.");
            }
            values = new NSDictionary<String, Object>(primaryKeyValue, entity.primaryKeyAttributeNames().lastObject());
        }
        NSArray eos;
        if (prefetchingKeyPaths == null && !refreshRefetchedObjects) {
          EOGlobalID gid = entity.globalIDForRow(values);
          EOEnterpriseObject eo = ec.faultForGlobalID(gid, ec);
View Full Code Here

     *
     * @return primary keys in the given range
     */
    public static NSArray<NSDictionary<String, Object>> primaryKeyValuesInRange(EOEditingContext ec, EOFetchSpecification spec, int start, int end) {
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, spec.entityName());
        NSArray<String> pkNames = entity.primaryKeyAttributeNames();
        EOFetchSpecification clonedFetchSpec = (EOFetchSpecification)spec.clone();
        clonedFetchSpec.setFetchesRawRows(true);
        clonedFetchSpec.setRawRowKeyPaths(pkNames);
        if (clonedFetchSpec instanceof ERXFetchSpecification) {
            // remove any range setting as we will explicitly set start and end limit
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public static NSDictionary<String, Object> newPrimaryKeyDictionaryForObjectFromClassProperties(EOEnterpriseObject eo) {
        EOEditingContext ec = eo.editingContext();
        EOEntity entity = EOUtilities.entityNamed(ec, eo.entityName());
        NSArray<String> pkAttributes = entity.primaryKeyAttributeNames();
        int count = pkAttributes.count();
        NSMutableDictionary<String, Object> nsmutabledictionary = new NSMutableDictionary<String, Object>(count);
        NSArray classPropertyNames = entity.classPropertyNames();
        while (count-- != 0) {
            String key = pkAttributes.objectAtIndex(count);
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public static EOGlobalID globalIDForString(EOEditingContext ec, String entityName, String string) {
      NSDictionary<String, Object> values = primaryKeyDictionaryForString(ec, entityName, string);
      EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
        NSArray<String> pks = entity.primaryKeyAttributeNames();
        EOGlobalID gid = EOKeyGlobalID.globalIDWithEntityName(entityName, values.objectsForKeys(pks, null).objects());
      return gid;
    }
   
    /**
 
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.