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

📄 ttestdao.java

📁 持久层hibernate技术使用的一个例子
💻 JAVA
字号:
package cn.hope.mana.pojo.dao;

import java.util.List;
import java.util.Vector;

import org.apache.log4j.Logger;

import net.sf.hibernate.HibernateException;
import cn.hope.mana.pojo.base.BaseTTestDAO;


public class TTestDAO extends BaseTTestDAO {

	Logger log = Logger.getLogger(TTestDAO.class.getName());
	
	/**
	 * Default constructor.  Can be used in place of getInstance()
	 */
	public TTestDAO () {}
	
	/*---------------liul--------------------------------------------------------------------------*/

	/**
	 * 查询试题是否存在Ttest表中
	 */
	public List U05searchTtest(Integer questionID) throws HibernateException {
		List list = null;
		String sqlStr = "select tTest from TTest tTest where tTest.flag='0' and tTest.TQuestion.tqId='"+questionID+"'";
		try {
			initialize();
			list = this.getSession().find(sqlStr);
		} catch (HibernateException e) {
			log.error(e);
			e.printStackTrace();
			throw new HibernateException(e);
		} finally {
			closeCurrentThreadSessions();
		}
		return list;
	}
	
	/**
	 * 查询试题是否存在Ttest表中
	 */
	public int searchTest(String[] a) throws HibernateException {
		List list = null;
		int k =0;
		if(a!=null && a.length>0){
			for(int j=0;j<a.length;j++){
				Integer i = new Integer(a[j]); 
				String sqlStr = "select tTest from TTest tTest where tTest.flag='0' and tTest.TQuestion.tqId='"+i+"'";
				try {
					initialize();
					 list = this.getSession().find(sqlStr);
					 if (list.size() > 0) {
						 k++;
					 }
				} catch (HibernateException e) {
					log.error(e);
					e.printStackTrace();
					throw new HibernateException(e);
				} finally {
					closeCurrentThreadSessions();
				}			
			}
		}
		return k;
	}
	
	/**
	 * 查询试题是否存在Ttest表中
	 */
	
	public Vector searchNotInTest(String[] a) throws HibernateException {
		List list = null;
		Vector v =new Vector();
		if(a!=null && a.length>0){
			for(int j=0;j<a.length;j++){
				Integer i = new Integer(a[j]); 
				String sqlStr = "select tTest from TTest tTest where tTest.flag='0' and tTest.TQuestion.tqId='"+i+"'";
				try {
					initialize();
					 list = this.getSession().find(sqlStr);
					 if (list.size() > 0 ) {
						 v.add(i);
					 }
				} catch (HibernateException e) {
					log.error(e);
					e.printStackTrace();
					throw new HibernateException(e);
				} finally {
					closeCurrentThreadSessions();
				}			
			}
		}
		return v;
	}
}

⌨️ 快捷键说明

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