/** * Will create a DynamicMapper on the specified target class. * @param target the class * @param <T> the jdbcMapper target type * @return the DynamicMapper */ public <T> DynamicJdbcMapper<T> newMapper(final Class<T> target) { return newMapper((Type) target); }
/** * Will create a DynamicMapper on the specified target class. * @param target the class * @param <T> the jdbcMapper target type * @return the DynamicMapper */ public <T> DynamicJdbcMapper<T> newMapper(final Class<T> target) { return newMapper((Type) target); }
@Override public ContextualSourceMapper<ResultSet, ?> newInstance(Type type) { return JdbcMapperFactory.newInstance().newMapper(type); } };
/** * Will create a DynamicMapper on the type specified by the TypeReference. * @param target the TypeReference * @param <T> the jdbcMapper target type * @return the DynamicMapper */ public <T> DynamicJdbcMapper<T> newMapper(final TypeReference<T> target) { return newMapper(target.getType()); }
@Override public ContextualSourceMapper<ResultSet, ?> newInstance(Class<?> aClass) { return JdbcMapperFactory.newInstance().newMapper(aClass); } };
/** * Will create a DynamicMapper on the type specified by the TypeReference. * @param target the TypeReference * @param <T> the jdbcMapper target type * @return the DynamicMapper */ public <T> DynamicJdbcMapper<T> newMapper(final TypeReference<T> target) { return newMapper(target.getType()); }
@Override public void handle(PreparedStatement ps) throws Exception { JdbcMapper<DbFinalObject> mapper = nonAsmFactory.newMapper(DbFinalObject.class); assertMapPsFinalDbObject(ps.executeQuery(), mapper); } });
@Override public void handle(PreparedStatement ps) throws Exception { JdbcMapper<DbObject> mapper = nonAsmFactory.newMapper(DbObject.class); assertMapPsDbObject(ps.executeQuery(), mapper); } });
@Override public void handle(PreparedStatement ps) throws Exception { JdbcMapper<DbObject> mapper = asmFactory.newMapper(DbObject.class); assertMapPsDbObject(ps.executeQuery(), mapper); } });
@Override public void handle(PreparedStatement ps) throws Exception { JdbcMapper<DbFinalObject> mapper = asmFactory.newMapper(DbFinalObject.class); assertMapPsFinalDbObject(ps.executeQuery(), mapper); } });
@Override public void handle(PreparedStatement ps) throws Exception { ResultSet rs = ps.executeQuery(); JdbcMapper<DbObject> mapper = asmFactory.newMapper(DbObject.class, rs.getMetaData()); assertMapPsDbObject(rs, mapper); } });
@Override public void handle(PreparedStatement ps) throws Exception { ResultSet rs = ps.executeQuery(); JdbcMapper<DbObject> mapper = nonAsmFactory.newMapper(DbObject.class, rs.getMetaData()); assertMapPsDbObject(rs, mapper); } });
@Override public void handle(PreparedStatement ps) throws Exception { ResultSet rs = ps.executeQuery(); JdbcMapper<DbObjectWithEmptyAlias> mapper = asmFactory.newMapper(DbObjectWithEmptyAlias.class, rs.getMetaData()); assertMapPsDbObjectWithEmptyAlias(rs, mapper); } });
@Override public void handle(PreparedStatement ps) throws Exception { ResultSet rs = ps.executeQuery(); JdbcMapper<DbObjectWithAlias> mapper = asmFactory.newMapper(DbObjectWithAlias.class, rs.getMetaData()); assertMapPsDbObjectWithAlias(rs, mapper); } });
public void selectUsers() { JdbcMapper<Object> jdbcMapper = JdbcMapperFactory .newInstance() .addKeys("id", "roles_id", "phones_id") .newMapper(Object.class); }
@Test public void testJoinTableCNoAsm() throws Exception { final JdbcMapper<ProfessorC> mapper = noAsmJdbcMapperFactory.newMapper(ProfessorC.class); validateMapper(mapper); assertNotNull(mapper.toString()); }
@Test public void testMapConstructor() { JdbcMapperFactory.newInstance().addKeys("id").newMapper(MyPojo.class); } @Test
@Test public void testMapSG() { JdbcMapperFactory.newInstance().addKeys("id").newMapper(MyPojo2.class); } }
@Test public void testMapExtendedType() throws Exception { final JdbcMapper<DbExtendedType> mapper = JdbcMapperFactoryHelper.asm().newMapper(DbExtendedType.class); DbHelper.testQuery(new TestRowHandler<PreparedStatement>() { @Override public void handle(PreparedStatement t) throws Exception { List<DbExtendedType> list = mapper.forEach(t.executeQuery(), new ListCollector<DbExtendedType>()).getList(); assertEquals(1, list.size()); DbExtendedType o = list.get(0); assertDbExtended(o); } }, "select * from db_extended_type"); }
@Test public void testFactoryOnTuples() { assertNotNull(asmFactory.newMapper(Tuples.typeDef(Date.class, Date.class))); assertNotNull(asmFactory.newBuilder(Tuples.typeDef(Date.class, Date.class))); }