摘要: MySql的like语句中的通配符:百分号、下划线和escape %代表任意多个字符 _代表一个字符 escape,转义字符后面的%或_,使其不作为通配符,而是普通字符匹配 数据库数据如下: 1.查找名字中以Lucy的字段 查询语句: select * from `user` where name 阅读全文
posted @ 2016-07-12 16:36 SaraMorning 阅读(11718) 评论(0) 推荐(0) 编辑
摘要: 查询语句格式: select 字段名,分组函数 from tableName [where 查询条件][group by 分组字段][having 分组函数][order by 排序字段] 分组函数:avg([distinct]字段名)、count({*[distinct]字段名})、max([di 阅读全文
posted @ 2016-07-11 15:43 SaraMorning 阅读(1622) 评论(0) 推荐(0) 编辑
摘要: Spring 中 org.springframework.util.Assert 类实现合法性检测,Assert的方法如下: 断言方法说明: 1. notNull(Object object) 当 object 不为 null 时抛出异常,notNull(Object object, String 阅读全文
posted @ 2016-07-10 20:13 SaraMorning 阅读(793) 评论(0) 推荐(0) 编辑
摘要: 字符集编码系列:http://my.oschina.net/goldenshaw/blog?catalog=536953&temp=1468116377592 乱码探源:http://my.oschina.net/goldenshaw/blog?catalog=3294521&temp=146811 阅读全文
posted @ 2016-07-10 10:10 SaraMorning 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 打开cache后query的list和iterator方法区别 将query 的cache打开的话,缓存的是query本身,以hql 生成的 sql ,再加上参数,分页等信息做为key值,而不是query的结果.query的结果是放在session的cache中,和query的cache是有区别的. 阅读全文
posted @ 2016-07-09 22:03 SaraMorning 阅读(1326) 评论(0) 推荐(0) 编辑
摘要: 1、Test_query_list类 测试结果为: Hibernate: select user0_.id as id0_, user0_.name as name0_ from mydb.user user0_ where user0_.id<=3************************* 阅读全文
posted @ 2016-07-09 15:57 SaraMorning 阅读(423) 评论(0) 推荐(0) 编辑
摘要: get测试代码如下: 输出结果是: Hibernate: select user0_.id as id0_0_, user0_.name as name0_0_ from mydb.user user0_ where user0_.id=? User [id=3, name=sara3] load测 阅读全文
posted @ 2016-07-09 11:02 SaraMorning 阅读(204) 评论(0) 推荐(0) 编辑
摘要: applicationContext.xml 如果Spring也使用cache缓存则 (1) 在spring 集成hibernate 的配置文件中,修改如下cache相关配置 由于Spring也使用ehcache, 所以也需要在spring配置文件中添加ehcache的配置 ehcache.xml文 阅读全文
posted @ 2016-07-07 21:52 SaraMorning 阅读(729) 评论(0) 推荐(0) 编辑
摘要: 1、构造BaseDao泛型类 class BaseDao<T>{ private Class<T> entityClass; // 通过反射获取实际运行的精确类 public BaseDao() { Type genType = getClass().getGenericSuperclass(); 阅读全文
posted @ 2016-07-07 16:35 SaraMorning 阅读(977) 评论(0) 推荐(0) 编辑
摘要: 本文主要讲一讲Hibernate+EhCache配置二级缓存的基本使用方法 (有关EhCache的基础介绍可参见:http://sjsky.iteye.com/blog/1288257 ) Cache的多种配置方法 Javabean cache的配置有三种,下面将一一介绍,具体如下:: (1)bea 阅读全文
posted @ 2016-07-06 11:02 SaraMorning 阅读(4052) 评论(0) 推荐(0) 编辑