diff --git a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/RowToObjectMapper.java b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/RowToObjectMapper.java index 90d1eee..c5bf3bc 100644 --- a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/RowToObjectMapper.java +++ b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/RowToObjectMapper.java @@ -143,6 +143,7 @@ public class RowToObjectMapper extends RowMapper { * * @return An object instance. */ + @SuppressWarnings({"unchecked"}) public T mapRowToReturnType() { if (resultSetConstructor) @@ -195,7 +196,7 @@ public class RowToObjectMapper extends RowMapper { try { if (typeId != TypeMappingsFactory.TYPE_UNKNOWN) { - return _returnTypeClass.cast(extractColumnValue(1, typeId)); + return (T)extractColumnValue(1, typeId); } else { // we still might want a single value (i.e. java.util.Date) Object val = extractColumnValue(1, typeId); diff --git a/beehive-jdbc-mapper/src/test/java/com/moparisthebest/jdbc/QueryMapperTest.java b/beehive-jdbc-mapper/src/test/java/com/moparisthebest/jdbc/QueryMapperTest.java index 5f80f85..bd9368d 100644 --- a/beehive-jdbc-mapper/src/test/java/com/moparisthebest/jdbc/QueryMapperTest.java +++ b/beehive-jdbc-mapper/src/test/java/com/moparisthebest/jdbc/QueryMapperTest.java @@ -221,6 +221,18 @@ public class QueryMapperTest { Assert.assertEquals(map, qm.toMap("SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4", Long.class, Long.class)); } + @Test + public void testSelectLongObject() throws Throwable { + final Long expected = fieldPerson1.getPersonNo(); + Assert.assertEquals(expected, qm.toObject("SELECT person_no FROM person WHERE person_no = ?", Long.class, expected)); + } + + @Test + public void testSelectLongPrimitive() throws Throwable { + final Long expected = fieldPerson1.getPersonNo(); + Assert.assertEquals(expected, qm.toObject("SELECT person_no FROM person WHERE person_no = ?", long.class, expected)); + } + private List> getListMap() { final List> arrayMap = new ArrayList>();