Session是应用程序与数据库之间的一个会话,其重要性不言而喻.初学Hibernate,使用SessionFactory,老老实实地打开事务,提交,回滚,关闭session. 1.直接通过SessionFactory构建Session对象(用openSession()或者getCurrentSession()),例子如下: try { SessionFactory sf = new Configuration().configure().buildSessionFactory(); Sessi…
参考:http://www.cnblogs.com/renrenqq/archive/2006/08/04/467688.html 但这个方法还不能解决Session缓存问题,由于创建Session需要消耗大量的内存,参考上面的方法,当请求并发的时候,内存不断的增加. 在网上找了很多种方法都没有解决.下面贴上主要代码: 1.接口请参考上面文章 using NHibernate; using System; using System.Collections.Generic; using Syste…