diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2007-04-08 15:13:43 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2007-04-08 15:13:43 +0000 |
commit | 3a9238ffe1c347d2b66aabd2e481984484cbf010 (patch) | |
tree | dd2dec9ebb6f464dbaf7551e218e1c012bddd935 /src/main/java/com/amazon/carbonado/gen | |
parent | 057f092c9b77a4b8efc0486a8ecf3b552de2cb9d (diff) |
Allow setting join property as null if Nullable. This will become useful when outer joins are supported.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/gen')
-rw-r--r-- | src/main/java/com/amazon/carbonado/gen/StorableGenerator.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java index cbfeab9..4934db3 100644 --- a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java @@ -945,16 +945,18 @@ public final class StorableGenerator<S extends Storable> { markOrdinaryPropertyDirty(b, property);
} else {
- // If passed value is null, throw an
- // IllegalArgumentException. Passing in null could also
- // indicate that the property should be unloaded, but
- // that is non-intuitive.
-
b.loadLocal(b.getParameter(0));
- Label notNull = b.createLabel();
- b.ifNullBranch(notNull, false);
- CodeBuilderUtil.throwException(b, IllegalArgumentException.class, null);
- notNull.setLocation();
+ if (property.isNullable()) {
+ // Don't attempt to extract internal properties from null.
+ b.ifNullBranch(setValue, true);
+ } else {
+ Label notNull = b.createLabel();
+ b.ifNullBranch(notNull, false);
+ CodeBuilderUtil.throwException
+ (b, IllegalArgumentException.class,
+ "Non-nullable join property cannot be set to null");
+ notNull.setLocation();
+ }
// Copy internal properties from joined object.
int count = property.getJoinElementCount();
|