Index: src/main/java/org/modeshape/jdbc/JcrResultSet.java =================================================================== --- src/main/java/org/modeshape/jdbc/JcrResultSet.java (revision 2512) +++ src/main/java/org/modeshape/jdbc/JcrResultSet.java (working copy) @@ -546,7 +546,11 @@ */ @Override public InputStream getBinaryStream( String columnLabel ) throws SQLException { - return (InputStream)getValueReturn(columnLabel, PropertyType.BINARY); + Object o = getValueReturn(columnLabel, PropertyType.BINARY); + if (o != null) { + return (InputStream) o; + } + return null; } /** @@ -586,7 +590,12 @@ */ @Override public boolean getBoolean( String columnLabel ) throws SQLException { - return (Boolean)getValueReturn(columnLabel, PropertyType.BOOLEAN); + + Object o = getValueReturn(columnLabel, PropertyType.BOOLEAN); + if (o != null) { + return ((Boolean) o).booleanValue(); + } + return Boolean.FALSE.booleanValue(); } /** @@ -713,7 +722,8 @@ */ @Override public Date getDate( String columnLabel ) throws SQLException { - Calendar calv = (Calendar)getValueReturn(columnLabel, PropertyType.DATE); + Calendar calv = (Calendar)getValueReturn(columnLabel, PropertyType.DATE); + if (calv == null) return null; return TimestampWithTimezone.createDate(calv.getTime()); } @@ -766,7 +776,11 @@ */ @Override public double getDouble( String columnLabel ) throws SQLException { - return (Double)getValueReturn(columnLabel, PropertyType.DOUBLE); + Object o = getValueReturn(columnLabel, PropertyType.DOUBLE); + if (o != null) { + return ((Double) o).doubleValue(); + } + return 0; } /** @@ -821,7 +835,7 @@ */ @Override public int getInt( String columnLabel ) throws SQLException { - notClosed(); + notClosed(); return (int)getLong(columnLabel); } @@ -841,8 +855,12 @@ * @see java.sql.ResultSet#getLong(java.lang.String) */ @Override - public long getLong( String columnLabel ) throws SQLException { - return (Long)getValueReturn(columnLabel, PropertyType.LONG); + public long getLong( String columnLabel ) throws SQLException { + Object o = getValueReturn(columnLabel, PropertyType.LONG); + if (o != null) { + return ( (Long) o).longValue(); + } + return 0; } /** @@ -1026,7 +1044,11 @@ */ @Override public String getString( String columnLabel ) throws SQLException { - return (String)getValueReturn(columnLabel, PropertyType.STRING); + Object o = getValueReturn(columnLabel, PropertyType.STRING); + if (o != null) { + return (String) o; + } + return null; } /** @@ -1216,7 +1238,7 @@ this.currentValue = getValueObject(value, type); } catch (PathNotFoundException pnfe) { - // do nothing, return null + // do nothing } catch (ItemNotFoundException e) { itemNotFoundUsingColunName(columnName); } catch (RepositoryException e) { Index: src/test/java/org/modeshape/jdbc/TestUtil.java =================================================================== --- src/test/java/org/modeshape/jdbc/TestUtil.java (revision 2510) +++ src/test/java/org/modeshape/jdbc/TestUtil.java (working copy) @@ -78,6 +78,7 @@ public static final String PROP_F = "propF"; public static final String PROP_G = "propG"; public static final String PROP_H = "propH"; + public static final String PROP_I = "propI"; } @@ -96,10 +97,10 @@ // The column names must match the number of columns in #TUPLES COLUMN_NAMES = new String[] {COLUMN_NAME_PROPERTIES.PROP_A, COLUMN_NAME_PROPERTIES.PROP_B, COLUMN_NAME_PROPERTIES.PROP_C, COLUMN_NAME_PROPERTIES.PROP_D, COLUMN_NAME_PROPERTIES.PROP_E, COLUMN_NAME_PROPERTIES.PROP_F, - COLUMN_NAME_PROPERTIES.PROP_G, COLUMN_NAME_PROPERTIES.PROP_H}; + COLUMN_NAME_PROPERTIES.PROP_G, COLUMN_NAME_PROPERTIES.PROP_H, COLUMN_NAME_PROPERTIES.PROP_I}; TABLE_NAMES = new String[] {"typeA", "typeB", "typeA", "", "typeA"}; // The TYPE_NAMES correspond to the column value types defined in #TUPLES - TYPE_NAMES = new String[] {STRING, LONG, PATH, REFERENCE, DOUBLE, BOOLEAN, DATE, BINARY}; + TYPE_NAMES = new String[] {STRING, LONG, PATH, REFERENCE, DOUBLE, BOOLEAN, DATE, BINARY, LONG}; NODE_NAMES = new String[] {"node1", "node2"}; // Provides the resultset rows @@ -110,13 +111,13 @@ */ TUPLES.add(new Object[] {"r1c1", new Long(1), null, null, new Double(1), new Boolean(true), DATE_INSTANCE, - new String("Heres my data at r1").getBytes()}); + new String("Heres my data at r1").getBytes(), null} ); TUPLES.add(new Object[] {"r2c1", new Long(2), null, null, new Double(2), new Boolean(false), DATE_INSTANCE, - new String("Heres my data r2 ").getBytes()}); + new String("Heres my data r2 ").getBytes(), null}); TUPLES.add(new Object[] {"r3c1", new Long(3), null, null, new Double(3), new Boolean(true), DATE_INSTANCE, - new String("Heres my data at r3 ").getBytes()}); + new String("Heres my data at r3 ").getBytes(), null}); TUPLES.add(new Object[] {"r4c1", 4L, null, null, 4D, new Boolean(true).booleanValue(), DATE_INSTANCE, - new String("Heres my data r4 ").getBytes()}); + new String("Heres my data r4 ").getBytes(), null}); } Index: src/test/java/org/modeshape/jdbc/JcrResultSetTest.java =================================================================== --- src/test/java/org/modeshape/jdbc/JcrResultSetTest.java (revision 2510) +++ src/test/java/org/modeshape/jdbc/JcrResultSetTest.java (working copy) @@ -185,6 +185,20 @@ } } + + /** + * MODE-1007 + * @throws SQLException + */ + @Test + public void shouldCallGetLongReturnZeroWhenNullUsingColumnName() throws SQLException { + int col = 8; + for (int i = 0; i < TestUtil.TUPLES.size(); i++) { + assertThat(resultSet.next(), is(true)); + assertThat(resultSet.getLong(TestUtil.COLUMN_NAMES[col]), is( new Long(0).longValue())); + + } + } @Test public void shouldCallGetLongUsingColumnName() throws SQLException {