diff --git a/RosettaJdbi3/src/main/java/com/hubspot/rosetta/jdbi3/RosettaRowMapperFactory.java b/RosettaJdbi3/src/main/java/com/hubspot/rosetta/jdbi3/RosettaRowMapperFactory.java index 0402102..ccfe8a6 100644 --- a/RosettaJdbi3/src/main/java/com/hubspot/rosetta/jdbi3/RosettaRowMapperFactory.java +++ b/RosettaJdbi3/src/main/java/com/hubspot/rosetta/jdbi3/RosettaRowMapperFactory.java @@ -4,6 +4,7 @@ import com.hubspot.rosetta.RosettaMapper; import com.hubspot.rosetta.util.SqlTableNameExtractor; import java.lang.reflect.Type; +import java.util.Map; import java.util.Optional; import org.jdbi.v3.core.config.ConfigRegistry; import org.jdbi.v3.core.generic.GenericTypes; @@ -35,7 +36,12 @@ public Optional> build(Type type, ConfigRegistry config) { private static boolean accepts(Type type, ConfigRegistry config) { Class rawType = GenericTypes.getErasedType(type); - if (rawType.isPrimitive() || rawType.isArray() || rawType.isAnnotation()) { + if ( + rawType.isPrimitive() || + rawType.isArray() || + rawType.isAnnotation() || + rawType.equals(Map.Entry.class) + ) { return false; } else if (rawType == Optional.class) { Optional optionalType = GenericTypes.findGenericParameter( diff --git a/RosettaJdbi3/src/test/java/com/hubspot/rosetta/jdbi3/RosettaRowMapperFactoryTest.java b/RosettaJdbi3/src/test/java/com/hubspot/rosetta/jdbi3/RosettaRowMapperFactoryTest.java index 51e564e..38f70be 100644 --- a/RosettaJdbi3/src/test/java/com/hubspot/rosetta/jdbi3/RosettaRowMapperFactoryTest.java +++ b/RosettaJdbi3/src/test/java/com/hubspot/rosetta/jdbi3/RosettaRowMapperFactoryTest.java @@ -3,6 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.List; +import java.util.Map; import org.junit.Test; public class RosettaRowMapperFactoryTest extends AbstractJdbiTest { @@ -21,5 +22,8 @@ public void itMapsObject() { TestObject actual = results.get(0); assertThat(actual).isEqualTo(expected); + + Map map = getDao().getAllMap(); + assertThat(map).containsOnly(Map.entry(1, expected)); } } diff --git a/RosettaJdbi3/src/test/java/com/hubspot/rosetta/jdbi3/TestDao.java b/RosettaJdbi3/src/test/java/com/hubspot/rosetta/jdbi3/TestDao.java index 8a9505b..380fde9 100644 --- a/RosettaJdbi3/src/test/java/com/hubspot/rosetta/jdbi3/TestDao.java +++ b/RosettaJdbi3/src/test/java/com/hubspot/rosetta/jdbi3/TestDao.java @@ -1,7 +1,9 @@ package com.hubspot.rosetta.jdbi3; import java.util.List; +import java.util.Map; import org.jdbi.v3.sqlobject.SqlObject; +import org.jdbi.v3.sqlobject.config.KeyColumn; import org.jdbi.v3.sqlobject.config.RegisterRowMapperFactory; import org.jdbi.v3.sqlobject.customizer.BindList.EmptyHandling; import org.jdbi.v3.sqlobject.statement.SqlQuery; @@ -12,6 +14,10 @@ public interface TestDao extends SqlObject { @SqlQuery("SELECT * FROM test_table") List getAll(); + @SqlQuery("SELECT * FROM test_table") + @KeyColumn("id") + Map getAllMap(); + @SqlQuery("SELECT * FROM test_list_table") List getAllList();