// operation should be either INSERT or UPDATE
 protected void trimModifyRow(AbstractRecord modifyRow, int operation) {
   if ((modifyRow == null) || modifyRow.isEmpty()) {
     return;
   }
   Collection fields = main[operation][RETURN_ONLY];
   if ((fields == null) || fields.isEmpty()) {
     return;
   }
   for (int i = modifyRow.size() - 1; i >= 0; i--) {
     DatabaseField field = modifyRow.getFields().get(i);
     if (fields.contains(field)) {
       modifyRow.remove(field);
     }
   }
 }
예제 #2
0
 /** INTERNAL: Build the result value for the row. */
 public Object buildObject(AbstractRecord row) {
   if (this.resultType == AUTO) {
     List values = row.getValues();
     if (values.size() == 1) {
       return row.getValues().get(0);
     } else {
       return row.getValues().toArray();
     }
   } else if (this.resultType == ARRAY) {
     return row.getValues().toArray();
   } else if (this.resultType == ATTRIBUTE) {
     // Use get with field for XML records.
     Object value = row.get(row.getFields().get(0));
     if (getValueConverter() != null) {
       value = getValueConverter().convertDataValueToObjectValue(value, this.session);
     }
     return value;
   }
   return row;
 }
예제 #3
0
 /**
  * INTERNAL: The results are *not* in a cursor, build the collection. Cache the results in
  * temporaryCachedQueryResults.
  */
 protected Object executeNonCursor() throws DatabaseException {
   Vector rows = getQueryMechanism().executeSelect();
   Object results = null;
   if (this.resultType == MAP) {
     results = getContainerPolicy().buildContainerFromVector(rows, this.session);
   } else if (this.resultType == VALUE) {
     if (!rows.isEmpty()) {
       AbstractRecord record = (AbstractRecord) rows.get(0);
       // Use get with field for XML records.
       results = record.get(record.getFields().get(0));
       if (getValueConverter() != null) {
         results = getValueConverter().convertDataValueToObjectValue(results, this.session);
       }
     }
   } else {
     int size = rows.size();
     ContainerPolicy containerPolicy = getContainerPolicy();
     results = containerPolicy.containerInstance(size);
     if (containerPolicy.shouldAddAll()) {
       if (size > 0) {
         List values = new ArrayList(size);
         for (int index = 0; index < size; index++) {
           AbstractRecord row = (AbstractRecord) rows.get(index);
           Object value = buildObject(row);
           values.add(value);
         }
         containerPolicy.addAll(values, results, this.session, rows, this);
       }
     } else {
       for (int index = 0; index < size; index++) {
         AbstractRecord row = (AbstractRecord) rows.get(index);
         Object value = buildObject(row);
         containerPolicy.addInto(value, results, this.session, row, this);
       }
     }
   }
   // Bug 6135563 - cache DataReadQuery results verbatim, as ObjectBuilder is not invoked
   cacheResult(results);
   return results;
 }
 /**
  * INTERNAL: Merge the provided row into this row. Existing field values in this row will be
  * replaced with values from the provided row. Fields not in this row will be added from provided
  * row. Values not in provided row will remain in this row.
  */
 public void mergeFrom(AbstractRecord row) {
   for (int index = 0; index < row.size(); ++index) {
     this.put(row.getFields().get(index), row.getValues().get(index));
   }
 }