diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2007-08-09 15:50:21 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2007-08-09 15:50:21 +0000 |
commit | a28709aabca96f19023370dd072cb3dc131e0e99 (patch) | |
tree | 3c429f854161824c2b8fb39e03c1905ecf895575 /src/main/java/com/amazon/carbonado/repo/jdbc | |
parent | 76874edfb087f74bc4d0f88397b9a4845f590479 (diff) |
Handle null value when converting String to Character.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/jdbc')
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java | 21 |
1 files changed, 21 insertions, 0 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 a1d3026..2f1c35c 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java @@ -1930,10 +1930,31 @@ class JDBCStorableGenerator<S extends Storable> { propertyType.toPrimitiveType() == TypeDesc.CHAR)
{
// Special case for converting String to character.
+
+ Label charWasNull = null;
+ if (property.isNullable()) {
+ charWasNull = b.createLabel();
+ LocalVariable temp = b.createLocalVariable(null, resultSetType);
+ b.storeLocal(temp);
+ b.loadLocal(temp);
+ b.ifNullBranch(charWasNull, true);
+ b.loadLocal(temp);
+ }
+
b.loadConstant(0);
b.invokeVirtual(String.class.getName(), "charAt",
TypeDesc.CHAR, new TypeDesc[] {TypeDesc.INT});
b.convert(TypeDesc.CHAR, propertyType);
+
+ if (charWasNull != null) {
+ Label skipNull = b.createLabel();
+ b.branch(skipNull);
+
+ charWasNull.setLocation();
+ b.loadNull();
+
+ skipNull.setLocation();
+ }
} else {
b.convert(resultSetType, propertyType);
}
|