注解开发中的@Results注解使用

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 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")
})
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);


}
posted on 2019-11-17 17:14  小猪_佩奇  阅读(6856)  评论(0编辑  收藏  举报