摘要: 在查询过程中根据过程中的结果进行其他查询,最后进行组装 接口 List<Shop> getShopListOrderByName(); List<Shop> getShopListOrderByName(); 测试 @Testpublic void testGetShopByTitleContain 阅读全文
posted @ 2019-03-17 10:51 不怕旅途多坎坷 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Shop实体类 package io.github.coinsjack.pojo;import java.io.Serializable;import java.sql.Date;public class Shop implements Serializable{ Area area; } pack 阅读全文
posted @ 2019-03-17 10:50 不怕旅途多坎坷 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 测试 @Test public void testCacheLevelOne1() { SqlSession session = MyBatisUtil.getSqlSession(); ShopMapper mapper = session.getMapper(ShopMapper.class); 阅读全文
posted @ 2019-03-17 10:46 不怕旅途多坎坷 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 二级缓存默认不开启, 开启之后, 可以在不同的session范围内执行相同的数据查询, 只进行一次数据库检索 开启设置 在mapper文件中 设置cache 在实体类中实现序列化接口, 否则会报错NotSerializableException 测试 @Testpublic void testCac 阅读全文
posted @ 2019-03-17 10:46 不怕旅途多坎坷 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 如果想要复用sql语句,就需要了解sql片段 改写先前的代码 接口 Shop getShopByIdAlias(Integer id); Shop getShopByIdAlias(Integer id); 映射文件 <sql id="columnAliasSql"> `shop_id` as `i 阅读全文
posted @ 2019-03-17 10:45 不怕旅途多坎坷 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 测试 @Testpublic void testCacheLevelOne() { SqlSession session = MyBatisUtil.getSqlSession(); ShopMapper mapper = session.getMapper(ShopMapper.class); S 阅读全文
posted @ 2019-03-17 10:45 不怕旅途多坎坷 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 需求 假设我们现在想要将用户勾选中的商铺批量删除或者进行批量其他操作 接口 int deleteShopInList(List<Integer> ids); int deleteShopInList(List<Integer> ids); 映射 在这里注意foreach的collection属性只有 阅读全文
posted @ 2019-03-17 10:12 不怕旅途多坎坷 阅读(1555) 评论(0) 推荐(0) 编辑
摘要: where元素会在90%的情况下管用,但是如果where不管用,可以试试trim元素 和where等价的trim <trim prefix="WHERE" prefixOverrides="AND |OR "> ... </trim> <trim prefix="WHERE" prefixOverr 阅读全文
posted @ 2019-03-17 10:11 不怕旅途多坎坷 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 需求 查询id小于10,并且shopname包含"关键词"的记录 如果用户没有输入任何关键词, 那么列出所有结果 接口 List<Shop> get10ShopByTitle(String value); List<Shop> get10ShopByTitle(String value); 映射 < 阅读全文
posted @ 2019-03-17 10:10 不怕旅途多坎坷 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 需求 如果用户限定了地址, 或者限定了名称, 或者都限定了, 给出用户想要的结果 接口 List<Shop> getShopListByCondition(Shop condition); List<Shop> getShopListByCondition(Shop condition); 映射 < 阅读全文
posted @ 2019-03-17 10:10 不怕旅途多坎坷 阅读(298) 评论(0) 推荐(0) 编辑