diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2007-09-17 00:30:11 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2007-09-17 00:30:11 +0000 |
commit | ef4d716bcbd1532dea306e2309b770d8d95e3bbe (patch) | |
tree | db6c9834cf7c73809638a4c5cbc5c1761227c736 | |
parent | d715c111d8a465cd3b32aae68463756b9c1db183 (diff) |
Missing many-to-one join always returns null now.
-rw-r--r-- | src/main/java/com/amazon/carbonado/gen/StorableGenerator.java | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java index 6a66528..e28f07c 100644 --- a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java @@ -617,18 +617,15 @@ public final class StorableGenerator<S extends Storable> { // Now load the object.
b.loadLocal(join);
- if (!property.isNullable()) {
- b.invokeInterface(storableDesc, LOAD_METHOD_NAME, null, null);
- } else {
- b.invokeInterface
- (storableDesc, TRY_LOAD_METHOD_NAME, TypeDesc.BOOLEAN, null);
- Label wasLoaded = b.createLabel();
- b.ifZeroComparisonBranch(wasLoaded, "!=");
- // Not loaded, so replace joined object with null.
- b.loadNull();
- b.storeLocal(join);
- wasLoaded.setLocation();
- }
+ // Always call "try load", even for non-nullable joins.
+ b.invokeInterface
+ (storableDesc, TRY_LOAD_METHOD_NAME, TypeDesc.BOOLEAN, null);
+ Label wasLoaded = b.createLabel();
+ b.ifZeroComparisonBranch(wasLoaded, "!=");
+ // Not loaded, so replace joined object with null.
+ b.loadNull();
+ b.storeLocal(join);
+ wasLoaded.setLocation();
} else {
// Generate query load form.
@@ -671,11 +668,9 @@ public final class StorableGenerator<S extends Storable> { // Just save and return the query.
b.storeLocal(join);
} else {
- String loadMethod =
- property.isNullable() ?
- TRY_LOAD_ONE_METHOD_NAME :
- LOAD_ONE_METHOD_NAME;
- b.invokeInterface(queryType, loadMethod, storableDesc, null);
+ // Always call "try load", even for non-nullable joins.
+ b.invokeInterface
+ (queryType, TRY_LOAD_ONE_METHOD_NAME, storableDesc, null);
b.checkCast(type);
b.storeLocal(join);
}
@@ -687,7 +682,14 @@ public final class StorableGenerator<S extends Storable> { b.loadLocal(join);
b.storeField(property.getName(), type);
- // Add code to identify this property as being loaded.
+ // Add code to identify this property as being loaded,
+ // except if value is null and join is not nullable.
+
+ if (!property.isNullable()) {
+ b.loadLocal(join);
+ b.ifNullBranch(isLoaded, true);
+ }
+
b.loadThis();
b.loadThis();
b.loadField(stateFieldName, TypeDesc.INT);
|