⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hibernateformdao.java

📁 OBPM是一个开源
💻 JAVA
字号:
package cn.myapps.core.dynaform.form.dao;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

import cn.myapps.base.action.ParamsTable;
import cn.myapps.base.dao.DataPackage;
import cn.myapps.base.dao.HibernateBaseDAO;
import cn.myapps.base.dao.ValueObject;
import cn.myapps.core.dynaform.form.ejb.Form;

public class HibernateFormDAO extends HibernateBaseDAO implements FormDAO {

	public HibernateFormDAO(String voClassName) {
		super(voClassName);
	}

	public Form findByFormName(String formName, String application)
			throws Exception {
		String hql = "FROM " + _voClazzName + " vo WHERE vo.name = '"
				+ formName +"' and vo.applicationid = '" + application + "' ";
		
		return (Form)getData(hql);
//		   ParamsTable params=new ParamsTable();
//		   params.setParameter("application",application);
//		Collection list = getDatas(hql, params);
//		if (list != null && !list.isEmpty()) {
//			Iterator iter = list.iterator();
//			return (Form) iter.next();
//		} else {
//			return null;
//		}
	}

	public Collection getFormsByModule(String moduleid, String application)
			throws Exception {
		String hql = "FROM " + _voClazzName + " vo WHERE vo.module.id='"
				+ moduleid + "' AND vo.type <> 0";
		   ParamsTable params=new ParamsTable();
		   params.setParameter("application",application);
		   return getDatas(hql, params);
	}

	public Collection getSearchFormsByModule(String moduleid, String application)
			throws Exception {
		String hql = "FROM " + _voClazzName + " vo WHERE vo.module.id='"
				+ moduleid + "'" + " and vo.type='" + Form.FORM_TYPE_SEARCHFORM
				+ "'";
		   ParamsTable params=new ParamsTable();
		   params.setParameter("application",application);
		   return getDatas(hql, params);
	}

	public Collection getSearchFormsByApplication(String appid, String application)
			throws Exception {
		String hql = "FROM " + _voClazzName + " vo WHERE vo.application.id='"
				+ appid + "'" + " and vo.type='" + Form.FORM_TYPE_SEARCHFORM
				+ "'";
		   ParamsTable params=new ParamsTable();
		   params.setParameter("application",application);
		   return getDatas(hql, params);
	}

	public DataPackage queryForm(ParamsTable params, String application)
			throws Exception {
		String hql = "FROM " + _voClazzName + " vo WHERE vo.type <> 0";
		String _currpage = params.getParameterAsString("_currpage");
		String _pagelines = params.getParameterAsString("_pagelines");

		int page = (_currpage != null && _currpage.length() > 0) ? Integer
				.parseInt(_currpage) : 1;
		int lines = (_pagelines != null && _pagelines.length() > 0) ? Integer
				.parseInt(_pagelines) : Integer.MAX_VALUE;

		if (application != null && application.length() > 0) {
			hql+=" and vo.applicationid = '" + application + "' ";
		}
		return getDatapackage(hql, params, page, lines);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -