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

📄 tfiletypedao.java

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

import java.util.List;

import org.apache.log4j.Logger;

import net.sf.hibernate.HibernateException;
import cn.hope.front.pojo.TFileType;
import cn.hope.front.pojo.base.BaseTFileTypeDAO;

public class TFileTypeDAO extends BaseTFileTypeDAO {
	Logger log = Logger.getLogger(TFileTypeDAO.class.getName());
	public static void main(String[] args) {
		TFileTypeDAO TFileTypeDAO=new TFileTypeDAO();
		try {
			TFileTypeDAO.searchByKey(new Integer(1));
		} catch (HibernateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * Default constructor. Can be used in place of getInstance()
	 */
	public TFileTypeDAO() {
	}
	
	public TFileType searchByKey(Integer key)throws HibernateException
	{
		TFileType tft=new TFileType();
		try
		{
			initialize();
			tft=this.load(key);
			/*
			 * 强制延迟加载方法
			 * 	this.getSession().refresh(tft);
			 *	Hibernate.initialize(tft.getTFileType2s());
			 *	Set set=(Set)tft.getTFileType2s();
			 *	System.out.println(set.size());
			 */
			
		}catch (HibernateException e) {
			log.error(e);
			e.printStackTrace();
			throw new HibernateException(e);
		} finally {
			closeCurrentThreadSessions();
			
		}
		return tft;
	}///:~
	
	public List searchAll() throws HibernateException {
		List list = null;
		String sqlStr = "select tFileType from TFileType tFileType where tFileType.flag='0' ";
		try {
			initialize();
			list = this.getSession().find(sqlStr);
		} catch (HibernateException e) {
			log.error(e);
			e.printStackTrace();
			throw new HibernateException(e);
		} finally {
			closeCurrentThreadSessions();
		}
		return list;
	}
}

⌨️ 快捷键说明

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