zoukankan      html  css  js  c++  java
  • 注解开发中一对多的运用和使用注意项

    package com.hope.dao;

    import com.hope.domain.User;
    import com.sun.xml.internal.bind.v2.model.core.ID;
    import org.apache.ibatis.annotations.*;
    import org.apache.ibatis.mapping.FetchType;

    import java.util.List;

    /**
    * @author newcityman
    * @date 2019/11/15 - 22:59
    */
    public interface IUserDao {
    /**
    * 查询所有用户的信息
    * @return
    */
    @Select(value = "select * from user")
    @Results(id = "userMap",value = {
    @Result(id = true,column ="id" ,property ="userId" ),
    @Result(column = "username" ,property = "userName"),
    @Result(column = "sex",property = "userSex"),
    @Result(column = "address",property = "userAddress"),
    @Result(column = "birthday",property = "userBirthday"),
    @Result(column = "id",property = "accounts",
    many =@Many(select = "com.hope.dao.IAccountDao.findAccountById"
    ,fetchType = FetchType.LAZY)),
    })
    public List<User> findAll();

    /**
    * 根据用户的id,查询用户
    * @param id
    * @return
    */
    @Select("select * from user where id=#{id}")
    @ResultMap(value ={"userMap"} )
    User findOne(Integer id);

    /**
    * 根据用户名模糊查询
    * @param username
    * @return
    */
    @Select("select * from user where username like #{username}")
    @ResultMap("userMap")
    List<User> findByName(String username);


    }
  • 相关阅读:
    eclipse上运行spark程序
    Java实现高斯模糊算法处理图像
    Hadoop环境共享
    P1182 数列分段`Section II`
    NOIP2015题解
    镜面上的迷失之链 —— 二分判定性问题
    网络最大流
    [IOI2008]Island
    历史的进程——单调队列
    快速幂
  • 原文地址:https://www.cnblogs.com/newcityboy/p/11878333.html
Copyright © 2011-2022 走看看