public interface UserDao {
/**
* 用户的持久层接口
* @return
*/
@Select("select * from user ")
@Results({
@Result(id=true,property = "id",column = "id"),
@Result(property = "name" ,column = "name"),
@Result(property = "positions",column ="id" ,
javaType = List.class,
many=@Many(select="cn.itcast.dao.PositionDao.findById",
fetchType= FetchType.LAZY))
})
List<User> findAll();
public interface PositionDao {
@Select("select * from position p,(select pid from u_p where uid=#{id}) u where p.id in(u.pid)")
@Results({
@Result(id=true,property = "id",column = "id"),
@Result(property = "name" ,column = "name"),
@Result(property = "permissions",column ="id" ,
javaType = List.class,
many=@Many(select="cn.itcast.dao.PermissionDao.findById",
fetchType= FetchType.LAZY))
})
List<Position> findById();
}
public interface PermissionDao {
@Select("select * from permission p,(select prid from ps_pr where psid=#{id}) u where p.id in (u.prid) ")
@Results({
@Result(id=true,property = "id",column = "id"),
@Result(property = "name" ,column = "name")
})
List<Permission> findById();
} |
|