I'm unsure of which of the above to use in our DAOs (which extend HibernateDAOSupport).
The SpringFramework API doc on HibernateTemplate.getSession() is thus:
protected Session getSession()
Return a Session for use by this template.
Returns a new Session in case of alwaysUseNewSession" (using the same JDBC Connection as a transactional Session, if applicable), a pre-bound Session in case of "allowCreate" turned off, and a pre-bound or new Session else (new only if no transactional or otherwise pre-bound Session exists).
The SpringFramework API doc on getSession() is thus:
protected final Session getSession()
throws DataAccessResourceFailureException,
IllegalStateException
Get a Hibernate Session, either from the current transaction or a new one. The latter is only allowed if the "allowCreate" setting of this bean's HibernateTemplate is true.
Note that this is not meant to be invoked from HibernateTemplate code but rather just in plain Hibernate code. Either rely on a thread-bound Session (via HibernateInterceptor), or use it in combination with releaseSession.
In general, it is recommended to use HibernateTemplate, either with the provided convenience operations or with a custom HibernateCallback that provides you with a Session to work on. HibernateTemplate will care for all resource management and for proper exception conversion.
分享到:
相关推荐
request.getSession().doc
Map, Book> books = (Map, Book>)request.getSession().getServletContext().getAttribute("books"); Book book = books.get(bookid); System.out.println(book); //得到数量 int bookNum = Integer....
if (httpssessionmap.containsKey(userid)&&httpssessionmap.get(userid).equals(event.getSession())) { //userIds.remove(userid); httpssessionmap.remove(userid); if(u!=null && userid....
request.getSession (). GetAttributes() 答案: A 2. JSP页面需要创建仅在本页面使用的JavaBean的示例,为了完成此功能必须使用jsp:useBean的哪两个属性进行设置?(选择两个选项) A. id B. type C. name D. ...
验目的 ...HashMap, Integer> map = (HashMap, Integer>) req.getSession().getAttribute("sessionGoods"); 3.写入链接a标签实现对映射的访问 out.write("<a href='./ShowGoods'>继续购买</h1></a>");
String planeImage = request.getSession().getServletContext().getRealPath("/image").replace("\\", "/")+"/"+"symark.png"; //获取目标图片的路径String targetPic = request.getSession().getServletContext()....
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet execution ...
对hibernate的flush机制有兴趣可以看看
5.连接是单线程的,在整个httpRequest处理过程中是公用的,缓存在HttpContext context中 see ref NHibernateHelper.getSession... 6.增加log4net演示,这是一个强大的log记录组件. 這個免費OR Mapping的工具很強大, ...
Struts2Utils.getSession().setAttribute(Constants.JCFX_COUNTY, orgList.get(0).get("DISTRICT_CODE") 查看redis数据库中的数据(需要用32位的jdk): java -jar redisclient-win32.x86.1.5.jar 在90.221要查看...
.getSession().getServletContext()); MultipartHttpServletRequest multipartRequest = resolver .resolveMultipart(request); MultipartFile file = multipartRequest.getFile("fileList"); 这个file就能...
js:(jsp页面引入md5.js文件) var mobile=$("input[name='mobile']").val(); var hash1=hex_md5(mobile); $("input[name='hidmobile']").val... request.getSession().setAttribute("actList", actList); } }
if ("xjg".equals(userName) && "xjg".equals... request.getSession().setAttribute("userName", userName); response.sendRedirect("success.jsp"); }else { response.sendRedirect("fail.jsp"); }
List<Article> alist1 = (List)request.getSession().getAttribute("alist1"); Iterator<Article> in1 = alist1.iterator(); List<Article> alist2 = (List)request.getSession().getAttribute("alist2"); ...
通过ActionContext.getContext().getSession().put("random", randomNum.getRandomCode())将数字存放到session当中 2、当你登录时候,提交的输入框中的验证码和session中存放的验证码比较,如果一样,则通过,不一样,则...
【官方解释】 getSession public HttpSession getSession(boolean create) Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a ...
Criteria c = super.getSession().createCriteria(Searchinfo.class); //构造函数 or Criterion ce = null ; for(String list:lists){ if(ce==null) ce = Restrictions.like("content", list); else ...
struts1.2 的上传和下载, 如果需要得到相对路径, 加一个 String path=request.getSession().getServletContext().getRealPath(); 就行了 ,这个就是comcat下的项目路径。
主要介绍了java 中 request.getSession(true/false/null)的区别的相关资料,需要的朋友可以参考下
UserAccessToken token = (UserAccessToken) request.getSession().getAttribute("UserAccessToken"); if(null==token){ token = util.getAccessToken3(Constants.APPID, Constants.SECRET,code); ...