zoukankan      html  css  js  c++  java
  • Hibernate 中Session 体会

    从一个web 工程体会到,如果有几个类:用户类、部门类、职工类,想要交换程序,怎么办呢?

    用session迅速解决。暂时感觉session就是一个池子,大家都可以放,大家都可以找。

    找的时候怎么找呢,这个就需要放的时候搞点技巧:添加一个tag,一个String就可以了。

    我的程序每一个类对应一个action,在这个action里面写了这段代码:

    	public String register(){	
    		ActionContext tx = ActionContext.getContext();	
    		User user = (User)ActionContext.getContext().getSession().get("user");
    		building.setUserId(user.getId());		
    		buildingService.add(building);
    		tx.getSession().put("building", building);
    		
    		if(buildingService.register(building)){
    			massage = "成功";
    			return "success";
    		}else{
    			massage = "失败";
    			return "index";
    		}
    	}
    

      

  • 相关阅读:
    HDU 2509 nim博弈
    HDU 1907 nim博弈变形
    HDU 1568 double 快速幂
    HDU 5950 矩阵快速幂
    HDU 1796 容斥原理
    Linux raid信息 查看
    Linux Ubuntu 内核升级
    Ubuntu 14.04 为 root 帐号开启 SSH 登录
    Google 分布式关系型数据库 F1
    分布式事务实现-Spanner
  • 原文地址:https://www.cnblogs.com/OleNet/p/2943586.html
Copyright © 2011-2022 走看看