1.Hibernate缓存html
hibernate有两级缓存,一级缓存又称为“Session的缓存”,二级缓存称为“SessionFactory的缓存”。sql
Session的缓存是事务范围的缓存(Session对象的生命周期一般对应一个数据库事务或者一个应用事务)。数据库
应用缓存,须要经过Session来进行操做,同时官网提供了@Cache注解。apache
第二级缓存是可选的,是一个可配置的插件,默认下SessionFactory不会启用这个插件。缓存
引用:官网 hibernate缓存机制详细分析mybatis
2.Hibernate级联操做app
级联操做对应的是数据库的外键,能够代替到外键的做用。ide
http://www.javashuo.com/article/p-zwzyzljy-ep.htmlpost
3.Scanner的用法ui
Scanner scan = new Scanner(System.in); String str = scan.next(); int a = scan.nextInt(); if (scan.hasNextLine()) { String str2 = scan.nextLine(); System.out.println("输入的数据为:" + str2); }
4.MyBatis使用xml配置
关键配置就一句
#配置.xml文件路径 mybatis.mapper-locations=classpath:mapper/*.xml
而后你能够在mapper.xml中指定一些sql了。
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> <mapper namespace="com.chriswei.cache.mapper.EmployeeMapper"> <select id="getEmployeeById" parameterType="Integer" resultType="com.chriswei.cache.bean.Employee"> SELECT * FROM Employee WHERE ID = #{id} </select> </mapper>
在namespace指定好路径以后,只要id跟service层的方法名字同样,就能够查询了。