summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-09-17 00:30:11 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-09-17 00:30:11 +0000
commitef4d716bcbd1532dea306e2309b770d8d95e3bbe (patch)
treedb6c9834cf7c73809638a4c5cbc5c1761227c736 /src
parentd715c111d8a465cd3b32aae68463756b9c1db183 (diff)
Missing many-to-one join always returns null now.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/amazon/carbonado/gen/StorableGenerator.java38
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);