Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ public Reader getNCharacterStream() throws SQLException {
}

public <T> T getObject(Class<T> type) throws SQLException {
Object val = getObject();
if (val == null || type == null || type.isAssignableFrom(val.getClass())) {
return (T) val;
}
throw cannotConvert("Object (with type)");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ public void testBigDecimalZeroScale() throws SQLException {
assertEquals(orig, accessor.getBigDecimal(0));
}


@Test
public void testGetLongObjectWithType() throws SQLException {
final Long orig = 1337L;
NumberAccessor accessor = new AbstractCursor.NumberAccessor(
new Getter() {
@Override public Object getObject() {
return orig;
}

@Override public boolean wasNull() {
return false;
}
},
0);

assertEquals(orig, accessor.getObject(Long.class));
}


}

// End NumberAccessorTest.java