public int update(GenericEntity entity) throws GenericEntityException { ModelEntity modelEntity = entity.getModelEntity(); if (modelEntity == null) { throw new GenericModelException("Could not find ModelEntity record for entityName: " + entity.getEntityName()); } // we don't want to update ALL fields, just the nonpk fields that are in the passed GenericEntity List partialFields = new ArrayList(); Collection keys = entity.getAllKeys(); for (int fi = 0; fi < modelEntity.getNopksSize(); fi++) { ModelField curField = modelEntity.getNopk(fi); if (keys.contains(curField.getName())) partialFields.add(curField); } return customUpdate(entity, modelEntity, partialFields); }
public int update(GenericEntity entity) throws GenericEntityException { ModelEntity modelEntity = entity.getModelEntity(); if (modelEntity == null) { throw new GenericModelException("Could not find ModelEntity record for entityName: " + entity.getEntityName()); } // we don't want to update ALL fields, just the nonpk fields that are in the passed GenericEntity List partialFields = new ArrayList(); Collection keys = entity.getAllKeys(); for (int fi = 0; fi < modelEntity.getNopksSize(); fi++) { ModelField curField = modelEntity.getNopk(fi); if (keys.contains(curField.getName())) partialFields.add(curField); } return customUpdate(entity, modelEntity, partialFields); }
/** * Updates the given entity with the given non-PK values. * * @param entity the values to store (except the primary key fields, which * are used to identify the row to be updated) * @param nonPkCondition an optional non-PK condition upon the update * @return the number of rows updated (always 1) * @throws GenericEntityNotFoundException if the entity wasn't found by its PK or doesn't meet the non-PK condition, * if any * @throws GenericEntityException */ public int update(final GenericEntity entity, final EntityConditionParam nonPkCondition) throws GenericEntityException { final ModelEntity modelEntity = entity.getModelEntity(); if (modelEntity == null) { throw new GenericModelException("Could not find ModelEntity for entityName: " + entity.getEntityName()); } // we don't want to update ALL fields, just the nonpk fields that are in the passed GenericEntity final List<ModelField> partialFields = new ArrayList<ModelField>(); final Collection<String> keys = entity.getAllKeys(); for (int fi = 0; fi < modelEntity.getNopksSize(); fi++) { final ModelField curField = modelEntity.getNopk(fi); if (keys.contains(curField.getName())) { partialFields.add(curField); } } return customUpdate(entity, modelEntity, partialFields, nonPkCondition); }
Collection keys = entity.getAllKeys();
Collection keys = entity.getAllKeys();
Collection<String> keys = entity.getAllKeys();