企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 配置 ~~~ <settings> <setting name="cacheEnabled" value="true"/> </settings> ~~~ ~~~ package com.like.dao; import com.like.domain.User; import java.util.List; import org.apache.ibatis.annotations.*; import org.apache.ibatis.mapping.FetchType; @CacheNamespace(blocking = true) //开启二级缓存 public interface IUserDao { @Select("select * from user") @Results(id = "userMap", value = { @Result(id = true, property = "id", column = "id"), @Result(property = "username", column = "username"), @Result(property = "address", column = "address"), @Result(property = "birthday", column = "birthday"), @Result(property = "sex", column = "sex"), //property是关联表在本表的属性,column是关联字段,select是关联接口根据id查询数据的全限定方法名,fetchType是获取方式,此处是立即获取 @Result(property = "accounts", column = "id", many = @Many(select = "com.like.dao.IAccountDao.findAccountByUid", fetchType = FetchType.LAZY)) }) List<User> findAll(); @Select("select * from user where id = #{id}") User findById(Integer id); } ~~~