zoukankan      html  css  js  c++  java
  • ssh框架下 写简单的hql语句

    author: myzhai

    ssh框架下 写简单的hql语句

    标签(空格分隔): 简单的hql 重要的在dao层 !!!


    • action
    @Autowired
    	private FlowActiveSrv	  flowActiveSrv;
    	private Integer			  pageSize;
    	
    private String findUserId() {
    	UserSession userSession = (UserSession) session.get("UserSession");
    	return userSession.getId();
    }
    
    //此处返回的是一个List<FlowActive>集合
    public void findMyApply() {
    	String userId = this.findUserId();
    	List<FlowActive> list =this.flowActiveSrv.findMyApply(userId, pageSize);
    	this.sendResponseMsg(list);
    }
    
    //处理一下
    protected void sendResponseMsg(Object src) {
    	final Gson g = new GsonBuilder().setDateFormat(DateFormat.DateTime.getFormat()).create();
    	this.sendResponseMsg(g.toJson(src));
    }
    
    • serviseImpl
    @Autowired
    private FlowActiveDao flowActiveDao;
    
    @Override
    public List<FlowActive> findMyApply(String userId,int pageSize) {
    	return flowActiveDao.findMyApply(userId,pageSize);
    }
    
    • daoImpl
    @Override
    public List<FlowActive> findMyApply(String userId,int pageSize) {
    	if (StringUtils.isBlank(userId)) {
    		return Lists.newArrayList();
    	}
    	Map<String, Object> values = new HashMap<String, Object>();
    	String hql = "FROM FlowActive where step != 99 and applyPersonId = :applyPersonId order by createTime desc";
    	values.put("applyPersonId", userId);
    	Query query = createHqlQuery(hql, values);
    	query.setFirstResult(0);
    	query.setMaxResults(pageSize);
    	@SuppressWarnings("unchecked")
    	List<FlowActive> list = query.list();
    	return list.isEmpty() ? Lists.newArrayList() : list;
    }
    
    • js 调用方法后台 填充模板
    //这里使用的模板填充 template.js
    // http://www.cnblogs.com/shiyou00/p/6841801.html
    //http://www.jq22.com/jquery-info1097
    
    function loadApplyData() {
        $.post(applyAction + "!findMyApply", { pageSize: 5 }, function(data) {
            var html = template("gridApplyTpl", { 'results': data });
            $("#gridApplyBody").html(html);
        }, "json")
    }
    
    • 以上代码尚未贴出get,set方法,接口等
  • 相关阅读:
    android中接口和抽象类的区别
    最靠谱的禁止ViewPager滑动方法
    Android Studio 自定义属性,命名空间
    代码设置Android EditText的相关问题。输入长度maxLength
    关于Android中,保留小数点后两位的方式
    Android的线程使用来更新UI----Thread、Handler、Looper、TimerTask等
    既然安卓免费,那 Google 是靠什么赚钱的?
    android viewconfiguration
    Android中实现为TextView添加多个可点击的文本
    Textview解析带图片的html示例
  • 原文地址:https://www.cnblogs.com/wisdombud/p/7157433.html
Copyright © 2011-2022 走看看