java - mybatis的注解sql怎么設置返回類型和查詢參數,比如我要返回一個封裝好的類里面有map屬性的
問題描述
/** * OrderMapper接口 * */public interface OrderMapper { /** * 查詢所有訂單 * @return 訂單對象集合 * */ @Select(' select Oid,Uname,Odate,Ostate from OrderInfoa,UserInfo where Ostate=’未發貨’ and OrderInfoa.Uid=UserInfo.Uid group by Oid ') List<PageData> findAll(); }比如上面,我是想多表查詢需要的字段然后想返回一個PageData,這個類是我寫好的,有map屬性的
問題解答
回答1:http://www.mybatis.org/mybati...
回答2:在@Select注解上使用@Results注解作為類型映射
@Results(value = { @Result(id = true, property = 'id', column = 'id', javaType = Long.class, jdbcType = JdbcType.BIGINT), @Result(property = 'title', column = 'title', javaType = String.class, jdbcType = JdbcType.VARCHAR) ... })
這是用注解的方式,也可以用xml的resultMap標簽配置類型映射具體可以看http://www.mybatis.org/mybati...
