コード例 #1
0
 @Override
 public int compare(RowKey key1, RowKey key2) {
   CompareToBuilder builder = new CompareToBuilder();
   for (String name : sortFields) {
     builder.append(key1.getColumnValue(name), key2.getColumnValue(name));
   }
   return builder.toComparison();
 }
コード例 #2
0
 /**
  * Remove an association row
  *
  * @param executionEngine the {@link ExecutionEngine} used to run the query
  * @param associationKey represents the association
  * @param rowKey represents a row in an association
  */
 public void removeAssociationRow(
     ExecutionEngine executionEngine, AssociationKey associationKey, RowKey rowKey) {
   Object[] relationshipValues;
   if (associationKey.getMetadata().getRowKeyIndexColumnNames().length > 0) {
     int length = associationKey.getMetadata().getRowKeyIndexColumnNames().length;
     relationshipValues = new Object[length];
     String[] indexColumnNames = associationKey.getMetadata().getRowKeyIndexColumnNames();
     for (int i = 0; i < indexColumnNames.length; i++) {
       for (int j = 0; j < rowKey.getColumnNames().length; j++) {
         if (indexColumnNames[i].equals(rowKey.getColumnNames()[j])) {
           relationshipValues[i] = rowKey.getColumnValues()[j];
         }
       }
     }
   } else {
     relationshipValues = getEntityKey(associationKey, rowKey).getColumnValues();
   }
   Object[] queryValues =
       ArrayHelper.concat(associationKey.getEntityKey().getColumnValues(), relationshipValues);
   executionEngine.execute(removeAssociationRowQuery, params(queryValues));
 }
コード例 #3
0
  /**
   * Returns the entity key on the other side of association row represented by the given row key.
   *
   * <p><b>Note:</b> May only be invoked if the row key actually contains all the columns making up
   * that entity key. Specifically, it may <b>not</b> be invoked if the association has index
   * columns (maps, ordered collections), as the entity key columns will not be part of the row key
   * in this case.
   */
  private EntityKey getEntityKey(AssociationKey associationKey, RowKey rowKey) {
    String[] associationKeyColumns =
        associationKey.getMetadata().getAssociatedEntityKeyMetadata().getAssociationKeyColumns();
    Object[] columnValues = new Object[associationKeyColumns.length];
    int i = 0;

    for (String associationKeyColumn : associationKeyColumns) {
      columnValues[i] = rowKey.getColumnValue(associationKeyColumn);
      i++;
    }

    EntityKeyMetadata entityKeyMetadata =
        associationKey.getMetadata().getAssociatedEntityKeyMetadata().getEntityKeyMetadata();
    return new EntityKey(entityKeyMetadata, columnValues);
  }
コード例 #4
0
 public SerializableRowKey(RowKey key) {
   columnNames = key.getColumnNames();
   columnValues = key.getColumnValues();
 }