监控hibernate的二级缓存

默认监控是关闭的,在hibernate.properties中打开监控设置

#监控二级缓存
hibernate.generate_statistcs true
测试:

	@Test
	public void t2(){
		Session session = HibernateUtil.getInstance().getSession();
		session.beginTransaction();
		
		Emp e = (Emp) session.get(Emp.class, 1);
		//System.out.println(e.getId());
		
		session.getTransaction().commit();
		Statistics st = HibernateUtil.getInstance().getsf().getStatistics();
		System.out.println(st);
		
		session.close();
	}

结果如下

Statistics[start time=1379397879484,sessions opened=0,sessions closed=0,transactions=0,successful transactions=0,optimistic lock failures=0,flushes=0,connections obtained=0,statements prepared=0,statements closed=0,second level cache puts=0,second level cache hits=0,second level cache misses=0,entities loaded=0,entities updated=0,entities inserted=0,entities deleted=0,entities fetched=0,collections loaded=0,collections updated=0,collections removed=0,collections recreated=0,collections fetched=0,naturalId queries executed to database=0,naturalId cache puts=0,naturalId cache hits=0,naturalId cache misses=0,naturalId max query time=0,queries executed to database=0,query cache puts=0,query cache hits=0,query cache misses=0,update timestamps cache puts=0,update timestamps cache hits=0,update timestamps cache misses=0,max query time=0]




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值