java - mybatis的注解sql怎么设置返回类型和查询参数,比如我要返回一个封装好的类里面有map属性的
迷茫
迷茫 2017-04-18 10:49:37
0
2
650
/**
 * 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属性的
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

répondre à tous(2)
PHPzhong

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

黄舟

Utiliser l'annotation @Results comme mappage de type sur l'annotation @Select

@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)
            ...
            })

Cela se fait à l'aide d'annotations, vous pouvez également utiliser la balise xml resultMap pour configurer le mappage de types
Pour plus de détails, veuillez consulter http://www.mybatis.org/mybati...

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!