From 68aec4c2495be067a555fd8de9ffddedfb857f05 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Mon, 14 Apr 2008 04:18:55 +0000 Subject: Fix code generation bug with nullable column. --- .../java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java | 2 +- .../com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java | 7 +++++++ .../java/com/amazon/carbonado/repo/jdbc/JDBCStorableProperty.java | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/amazon/carbonado/repo/jdbc') 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 1abe8d8..933817e 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java @@ -1898,7 +1898,7 @@ class JDBCStorableGenerator { TypeDesc resultSetType = TypeDesc.forClass(resultSetGetMethod.getReturnType()); Label wasNull = b.createLabel(); - if (resultSetType.isPrimitive() && property.isNullable()) { + if (resultSetType.isPrimitive() && property.isColumnNullable()) { b.loadLocal(rsVar); b.invokeInterface (TypeDesc.forClass(ResultSet.class), "wasNull", TypeDesc.BOOLEAN, null); diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java index a2d9181..d14818a 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java @@ -1125,6 +1125,7 @@ public class JDBCStorableIntrospector extends StorableIntrospector { private final String mColumnName; private final Integer mDataType; private final String mDataTypeName; + private final boolean mColumnNullable; private final Method mResultSetGet; private final Method mPreparedStatementSet; private final StorablePropertyAdapter mAdapter; @@ -1151,6 +1152,7 @@ public class JDBCStorableIntrospector extends StorableIntrospector { mColumnName = columnInfo.columnName; mDataType = columnInfo.dataType; mDataTypeName = columnInfo.dataTypeName; + mColumnNullable = columnInfo.nullable; mResultSetGet = resultSetGet; mPreparedStatementSet = preparedStatementSet; mAdapter = adapter; @@ -1166,6 +1168,7 @@ public class JDBCStorableIntrospector extends StorableIntrospector { mColumnName = null; mDataType = null; mDataTypeName = null; + mColumnNullable = false; mResultSetGet = null; mPreparedStatementSet = null; mAdapter = null; @@ -1325,6 +1328,10 @@ public class JDBCStorableIntrospector extends StorableIntrospector { return mDataTypeName; } + public boolean isColumnNullable() { + return mColumnNullable; + } + public Method getResultSetGetMethod() { return mResultSetGet; } diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableProperty.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableProperty.java index bbaf5fb..5e4c94f 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableProperty.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableProperty.java @@ -74,6 +74,12 @@ public interface JDBCStorableProperty extends StorableProper */ String getDataTypeName(); + /** + * @return true if column is nullable + * @since 1.2 + */ + boolean isColumnNullable(); + /** * Returns the method to use to access this property (by index) from a * ResultSet. -- cgit v1.2.3