Examples of primaryKeyAttributes()


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

          NSArray<String> primaryKeyAttributeNames = primaryKeyAttributeNames();
          _primaryKeyDictionary = new NSDictionary<String, Object>(rawPK instanceof NSArray ? (NSArray<Object>) rawPK : new NSArray<Object>(rawPK), primaryKeyAttributeNames);
        }
        else {
          EOEntity entity = entity();
          NSArray<EOAttribute> primaryKeyAttributes = entity.primaryKeyAttributes();
          // If the entity has a composite primary key, then we are
          // going to make
          // the assumption that we can determine its primary key from
          // the values
          // of the relationships that are bound to its primary key
View Full Code Here

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

   */
  private long maxIdFromTable(String ename) {
    EOEntity entity = EOModelGroup.defaultGroup().entityNamed(ename);
    if (entity == null) throw new NullPointerException("could not find an entity named " + ename);
    String tableName = entity.externalName();
    String colName = entity.primaryKeyAttributes().lastObject().columnName();
    String sql = "select max(" + colName + ") from " + tableName;

    ERXJDBCConnectionBroker broker = ERXJDBCConnectionBroker.connectionBrokerForEntityNamed(ename);
    Connection con = broker.getConnection();
    ResultSet resultSet;
View Full Code Here

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

     */
    public static ERXFetchSpecificationBatchIterator batchIteratorForObjectsWithSqlWithBindings( EOEditingContext ec, String entityName, String query, boolean refreshesCache, int batchSize, NSArray sortOrderings, ERXSQLBinding... bindings ) {
        EODatabaseContext databaseContext = databaseContextForEntityName(ec,entityName);
        EOEntity entity = EOUtilities.entityNamed(ec, entityName);

        if( entity.primaryKeyAttributes().count() > 1 ) {
            throw new RuntimeException("Multiple primary keys not supported.");
        }

        EOSQLExpression expression = databaseContext.adaptorContext().adaptor().expressionFactory().expressionForEntity( entity );
        expression.setStatement(processedQueryString(query, expression, bindings));
View Full Code Here

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

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

        for ( Enumeration rowEnumerator = pkDicts.objectEnumerator(); rowEnumerator.hasMoreElements(); ) {
            NSDictionary row = (NSDictionary) rowEnumerator.nextElement();
            pks.addObject( row.objectForKey( pkAtttributeName ));
        }
View Full Code Here

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

        EOEntity entity = EOUtilities.entityNamed(ec, entityName);
        NSDictionary<String, Object> values;
        if(primaryKeyValue instanceof NSDictionary) {
            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;
View Full Code Here

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

        if(string.trim().length()==0) {
            return NSDictionary.EmptyDictionary;
        }
       
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
        NSArray<EOAttribute> pks = entity.primaryKeyAttributes();
        NSMutableDictionary<String, Object> pk = new NSMutableDictionary<String, Object>();
        try {
            Object rawValue = NSPropertyListSerialization.propertyListFromString(string);
            if(rawValue instanceof NSArray) {
                int index = 0;
View Full Code Here

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

     
      if (rel != null) {
        lastRetriever = (Retriever<? extends PropertyContainer, V>) RelationshipRetriever.create(rel);       
      } else {
        EOAttribute att = current.attributeNamed(key);
        NSArray<EOAttribute> pks = current.primaryKeyAttributes();
       
        if (pks.size() == 1 && pks.get(0).equals(att)) {
          lastRetriever = (Retriever<? extends PropertyContainer, V>) PrimaryKeyRetriever.create(current);
        } else {
          // it must be an attribute
View Full Code Here

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

  @Override
  public boolean __hasNumericPrimaryKeys(EOClassDescription classDescription) {
    boolean numericPKs = false;
    if (classDescription instanceof EOEntityClassDescription) {
      EOEntity entity = ((EOEntityClassDescription)classDescription).entity();
      NSArray primaryKeyAttributes = entity.primaryKeyAttributes();
      if (primaryKeyAttributes.count() == 1) {
        EOAttribute primaryKeyAttribute = (EOAttribute) primaryKeyAttributes.objectAtIndex(0);
        Class primaryKeyClass = _NSUtilities.classWithName(primaryKeyAttribute.className());
        numericPKs = primaryKeyClass != null && Number.class.isAssignableFrom(primaryKeyClass);
      }
View Full Code Here

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

  }

  public Object objectOfEntityWithID(EOClassDescription entity, Object id, ERXRestContext context) {
    EOEntity eoEntity = ((EOEntityClassDescription) entity).entity();
    String strPKValue = String.valueOf(id);
    Object pkValue = eoEntity.primaryKeyAttributes().objectAtIndex(0).validateValue(strPKValue);
    EOEditingContext editingContext = context.editingContext();
    if (editingContext == null) {
      throw new IllegalArgumentException("There was no editing context attached to this rest context.");
    }
    editingContext.lock();
View Full Code Here

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

            String pk = (String)dictionary.objectForKey(SerializationKeys.PrimaryKey);
            EOEntity entity = ERXEOAccessUtilities.entityNamed(null, entityName);
            EOAttribute primaryKeyAttribute;
            EOEnterpriseObject eo = null;
            if (entity != null) {
                primaryKeyAttribute = ERXArrayUtilities.firstObject(entity.primaryKeyAttributes());
                Object primaryKeyObject = pk;
                if (log.isDebugEnabled()) log.debug("decodeEO with dict: " + dictionary);

                if (primaryKeyAttribute != null && !String.class.getName().equals(primaryKeyAttribute.className())) {
                    primaryKeyObject = ERXStringUtilities.integerWithString(pk);
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.