Heim  >  Fragen und Antworten  >  Hauptteil

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属性的
迷茫迷茫2744 Tage vor665

Antworte allen(2)Ich werde antworten

  • PHPz

    PHPz2017-04-18 10:51:37

    http://www.mybatis.org/mybati...

    Antwort
    0
  • 黄舟

    黄舟2017-04-18 10:51:37

    在@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...

    Antwort
    0
  • StornierenAntwort