summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-09-12 00:45:52 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-09-12 00:45:52 +0000
commita92760945cbc83d2f9f8543f6b905701b1b8ac6a (patch)
tree26883ac3feeeccd452e88a42b314834a3e3a7d9b /src
parenta602f34ec4b845a442b1152e02d655c4cd200acf (diff)
More lenient with Nullable Independent properties which aren't supported.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
index c8f636c..ca8188b 100644
--- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
+++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
@@ -222,19 +222,38 @@ class JDBCStorableGenerator<S extends Storable> {
defineExtractDataMethod(lobLoaderMap);
// For all unsupported properties, override get/set method to throw
- // UnsupportedOperationException.
+ // UnsupportedOperationException. Special treatment given if property
+ // is also Nullable. Get returns null and set only allows null.
{
for (JDBCStorableProperty<S> property : mAllProperties.values()) {
if (property.isDerived() || property.isJoin() || property.isSupported()) {
continue;
}
+
+ CodeBuilder b;
+ Class exClass = UnsupportedOperationException.class;
String message = "Independent property \"" + property.getName() +
"\" is not supported by the SQL schema: ";
- message += mInfo.getTableName();
- CodeBuilder b = new CodeBuilder(mClassFile.addMethod(property.getReadMethod()));
- CodeBuilderUtil.throwException(b, UnsupportedOperationException.class, message);
- b = new CodeBuilder(mClassFile.addMethod(property.getWriteMethod()));
- CodeBuilderUtil.throwException(b, UnsupportedOperationException.class, message);
+
+ if (property.isNullable()) {
+ b = new CodeBuilder(mClassFile.addMethod(property.getReadMethod()));
+ b.loadNull();
+ b.returnValue(TypeDesc.OBJECT);
+
+ b = new CodeBuilder(mClassFile.addMethod(property.getWriteMethod()));
+ b.loadLocal(b.getParameter(0));
+ Label notNull = b.createLabel();
+ b.ifNullBranch(notNull, false);
+ b.returnVoid();
+ notNull.setLocation();
+ CodeBuilderUtil.throwException(b, exClass, message);
+ } else {
+ message += mInfo.getTableName();
+ b = new CodeBuilder(mClassFile.addMethod(property.getReadMethod()));
+ CodeBuilderUtil.throwException(b, exClass, message);
+ b = new CodeBuilder(mClassFile.addMethod(property.getWriteMethod()));
+ CodeBuilderUtil.throwException(b, exClass, message);
+ }
}
}