diff options
-rw-r--r-- | src/main/java/com/amazon/carbonado/Storable.java | 4 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/spi/StorableGenerator.java | 36 |
2 files changed, 38 insertions, 2 deletions
diff --git a/src/main/java/com/amazon/carbonado/Storable.java b/src/main/java/com/amazon/carbonado/Storable.java index f5c2248..20c7ab7 100644 --- a/src/main/java/com/amazon/carbonado/Storable.java +++ b/src/main/java/com/amazon/carbonado/Storable.java @@ -416,8 +416,8 @@ public interface Storable<S extends Storable<S>> { String toString();
/**
- * Returns a string for debugging purposes that contains only supported
- * primary key property names and values for this object. Unsupported
+ * Returns a string for debugging purposes that contains supported
+ * key property names and values for this object. Unsupported
* {@link Independent independent} properties are not included.
*/
String toStringKeyOnly();
diff --git a/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java b/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java index f63a260..ecd344d 100644 --- a/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java @@ -3138,6 +3138,42 @@ public final class StorableGenerator<S extends Storable> { b.loadConstant('}');
invokeAppend(b, charParam);
+
+ // For key string, also show all the alternate keys. This makes the
+ // FetchNoneException message more helpful.
+ if (keyOnly) {
+ int altKeyCount = mInfo.getAlternateKeyCount();
+ for (int i=0; i<altKeyCount; i++) {
+ b.loadConstant(", {");
+ invokeAppend(b, stringParam);
+
+ StorableKey<S> key = mInfo.getAlternateKey(i);
+
+ ordinal = 0;
+ for (OrderedProperty<S> op : key.getProperties()) {
+ StorableProperty<S> property = op.getChainedProperty().getPrimeProperty();
+
+ Label skipPrint = b.createLabel();
+
+ // Check if independent property is supported, and skip if not.
+ if (property.isIndependent()) {
+ addSkipIndependent(b, null, property, skipPrint);
+ }
+
+ if (ordinal++ > 0) {
+ b.loadConstant(", ");
+ invokeAppend(b, stringParam);
+ }
+ addPropertyAppendCall(b, property, stringParam, charParam);
+
+ skipPrint.setLocation();
+ }
+
+ b.loadConstant('}');
+ invokeAppend(b, charParam);
+ }
+ }
+
b.invokeVirtual(stringBuilder, TO_STRING_METHOD_NAME, TypeDesc.STRING, null);
b.returnValue(TypeDesc.STRING);
}
|