From 3a9238ffe1c347d2b66aabd2e481984484cbf010 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 8 Apr 2007 15:13:43 +0000 Subject: Allow setting join property as null if Nullable. This will become useful when outer joins are supported. --- .../com/amazon/carbonado/gen/StorableGenerator.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/main/java/com') 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 { 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(); -- cgit v1.2.3