使用一个map映射出两个对象,再把两者关系对应起来

        String sql = "select * from book where bid =?";
            Map<String,Object> map = qr.query(sql, new MapHandler(),bid);
            //return qr.query(sql, new BeanHandler<Book>(Book.class),bid);
            
            /*
             * 使用一个map映射出两个对象,再把两者关系对应起来 
             */
            Category category = CommonUtils.toBean(map, Category.class);
            Book book = CommonUtils.toBean(map, Book.class);
            book.setCategory(category);

 

posted @ 2015-11-06 16:11  暗夜小精灵~~  阅读(529)  评论(0编辑  收藏  举报