@Test public void shouldReturnNullableBasedUponNodeTypeWhenResultIsExtendedJcrQueryResult() throws SQLException { assertThat(extMetadata.isNullable(1), is(ResultSetMetaData.columnNullable)); assertThat(extMetadata.isNullable(2), is(ResultSetMetaData.columnNoNulls)); assertThat(extMetadata.isNullable(3), is(ResultSetMetaData.columnNoNulls)); assertThat(extMetadata.isNullable(4), is(ResultSetMetaData.columnNullableUnknown)); assertThat(extMetadata.isNullable(5), is(ResultSetMetaData.columnNoNulls)); addPropDefn("typeB", "*", true); assertThat(extMetadata.isNullable(2), is(ResultSetMetaData.columnNoNulls)); }
@Override public int isNullable( int column ) throws SQLException { if (nullable == null) { int length = getColumnCount(); nullable = new int[length]; for (int i = 0; i != length; ++i) { nullable[i] = -1; } } else { int result = nullable[column - 1]; if (result != -1) { return result; } } String nodeTypeName = getTableName(column); if (nodeTypeName.length() == 0) { return ResultSetMetaData.columnNullableUnknown; } String propertyName = getColumnName(column); boolean singleProp = false; boolean singleResidual = false; boolean multiResidual = false; NodeType type = connection.nodeType(nodeTypeName); for (PropertyDefinition defn : type.getPropertyDefinitions()) { if (defn.getName().equals(propertyName)) { if (defn.isMultiple() || defn.isMandatory()) { return ResultSetMetaData.columnNullable; } singleProp = true; } else if (defn.getName().equals("*")) { if (defn.isMultiple() || defn.isMandatory()) multiResidual = true; else singleResidual = true; } } int result = ResultSetMetaData.columnNullableUnknown; if (multiResidual) result = ResultSetMetaData.columnNullable; else if (singleProp || singleResidual) result = ResultSetMetaData.columnNoNulls; nullable[column - 1] = result; return result; }
JcrResultSetMetaData implements ResultSetMetaData { @Override public int isNullable( int column ) throws SQLException { if (nullable == null) { int length = getColumnCount(); nullable = new int[length]; for (int i = 0; i != length; ++i) { nullable[i] = -1; } } else { int result = nullable[column - 1]; if (result != -1) { return result; } } String nodeTypeName = getTableName(column); if (nodeTypeName.length() == 0) { return ResultSetMetaData.columnNullableUnknown; } String propertyName = getColumnName(column); boolean singleProp = false; boolean singleResidual = false; boolean multiResidual = false; NodeType type = connection.nodeType(nodeTypeName); for (PropertyDefinition defn : type.getPropertyDefinitions()) { if (defn.getName().equals(propertyName)) { if (defn.isMultiple() || defn.isMandatory()) { return ResultSetMetaData.columnNullable; } singleProp = true; } else if (defn.getName().equals("*")) { if (defn.isMultiple() || defn.isMandatory()) multiResidual = true; else singleResidual = true; } } int result = ResultSetMetaData.columnNullableUnknown; if (multiResidual) result = ResultSetMetaData.columnNullable; else if (singleProp || singleResidual) result = ResultSetMetaData.columnNoNulls; nullable[column - 1] = result; return result; } }
JcrResultSetMetaData implements ResultSetMetaData { @Override public int isNullable( int column ) throws SQLException { if (nullable == null) { int length = getColumnCount(); nullable = new int[length]; for (int i = 0; i != length; ++i) { nullable[i] = -1; } } else { int result = nullable[column - 1]; if (result != -1) { return result; } } String nodeTypeName = getTableName(column); if (nodeTypeName.length() == 0) { return ResultSetMetaData.columnNullableUnknown; } String propertyName = getColumnName(column); boolean singleProp = false; boolean singleResidual = false; boolean multiResidual = false; NodeType type = connection.nodeType(nodeTypeName); for (PropertyDefinition defn : type.getPropertyDefinitions()) { if (defn.getName().equals(propertyName)) { if (defn.isMultiple() || defn.isMandatory()) { return ResultSetMetaData.columnNullable; } singleProp = true; } else if (defn.getName().equals("*")) { if (defn.isMultiple() || defn.isMandatory()) multiResidual = true; else singleResidual = true; } } int result = ResultSetMetaData.columnNullableUnknown; if (multiResidual) result = ResultSetMetaData.columnNullable; else if (singleProp || singleResidual) result = ResultSetMetaData.columnNoNulls; nullable[column - 1] = result; return result; } protected  JcrResultSetMetaData( JcrConnection connection,
                                    QueryResult results ); }
JcrResultSetMetaData implements ResultSetMetaData { @Override public int isNullable( int column ) throws SQLException { if (nullable == null) { int length = getColumnCount(); nullable = new int[length]; for (int i = 0; i != length; ++i) { nullable[i] = -1; } } else { int result = nullable[column - 1]; if (result != -1) { return result; } } String nodeTypeName = getTableName(column); if (nodeTypeName.length() == 0) { return ResultSetMetaData.columnNullableUnknown; } String propertyName = getColumnName(column); boolean singleProp = false; boolean singleResidual = false; boolean multiResidual = false; NodeType type = connection.nodeType(nodeTypeName); for (PropertyDefinition defn : type.getPropertyDefinitions()) { if (defn.getName().equals(propertyName)) { if (defn.isMultiple() || defn.isMandatory()) { return ResultSetMetaData.columnNullable; } singleProp = true; } else if (defn.getName().equals("*")) { if (defn.isMultiple() || defn.isMandatory()) multiResidual = true; else singleResidual = true; } } int result = ResultSetMetaData.columnNullableUnknown; if (multiResidual) result = ResultSetMetaData.columnNullable; else if (singleProp || singleResidual) result = ResultSetMetaData.columnNoNulls; nullable[column - 1] = result; return result; } protected  JcrResultSetMetaData( JcrConnection connection,
                                    QueryResult results ); @Override String getCatalogName( int column ); @Override String getColumnClassName( int column ); @Override int getColumnCount(); @Override int getColumnDisplaySize( int column ); @Override String getColumnLabel( int column ); @Override String getColumnName( int column ); @Override int getColumnType( int column ); @Override String getColumnTypeName( int column ); @Override int getPrecision( int column ); @Override int getScale( int column ); @Override String getSchemaName( int column ); @Override String getTableName( int column ); @Override boolean isAutoIncrement( int column ); @Override boolean isCaseSensitive( int column ); @Override boolean isCurrency( int column ); @Override boolean isDefinitelyWritable( int column ); @Override int isNullable( int column ); @Override boolean isReadOnly( int column ); @Override boolean isSearchable( int column ); @Override boolean isSigned( int column ); @Override boolean isWritable( int column ); @Override boolean isWrapperFor( Class<?> iface ); @Override T unwrap( Class<T> iface ); }
JcrResultSetMetaData implements ResultSetMetaData { @Override public int isNullable( int column ) throws SQLException { if (nullable == null) { int length = getColumnCount(); nullable = new int[length]; for (int i = 0; i != length; ++i) { nullable[i] = -1; } } else { int result = nullable[column - 1]; if (result != -1) { return result; } } String nodeTypeName = getTableName(column); if (nodeTypeName.length() == 0) { return ResultSetMetaData.columnNullableUnknown; } String propertyName = getColumnName(column); boolean singleProp = false; boolean singleResidual = false; boolean multiResidual = false; NodeType type = connection.nodeType(nodeTypeName); for (PropertyDefinition defn : type.getPropertyDefinitions()) { if (defn.getName().equals(propertyName)) { if (defn.isMultiple() || defn.isMandatory()) { return ResultSetMetaData.columnNullable; } singleProp = true; } else if (defn.getName().equals("*")) { if (defn.isMultiple() || defn.isMandatory()) multiResidual = true; else singleResidual = true; } } int result = ResultSetMetaData.columnNullableUnknown; if (multiResidual) result = ResultSetMetaData.columnNullable; else if (singleProp || singleResidual) result = ResultSetMetaData.columnNoNulls; nullable[column - 1] = result; return result; } protected  JcrResultSetMetaData( JcrConnection connection,
                                    QueryResult results ); @Override String getCatalogName( int column ); @Override String getColumnClassName( int column ); @Override int getColumnCount(); @Override int getColumnDisplaySize( int column ); @Override String getColumnLabel( int column ); @Override String getColumnName( int column ); @Override int getColumnType( int column ); @Override String getColumnTypeName( int column ); @Override int getPrecision( int column ); @Override int getScale( int column ); @Override String getSchemaName( int column ); @Override String getTableName( int column ); @Override boolean isAutoIncrement( int column ); @Override boolean isCaseSensitive( int column ); @Override boolean isCurrency( int column ); @Override boolean isDefinitelyWritable( int column ); @Override int isNullable( int column ); @Override boolean isReadOnly( int column ); @Override boolean isSearchable( int column ); @Override boolean isSigned( int column ); @Override boolean isWritable( int column ); @Override boolean isWrapperFor( Class<?> iface ); @Override T unwrap( Class<T> iface );  }