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

📄 daohibernatetemplate.java

📁 此项目是实现,增加,删除,修改,查询图书数据库的功能
💻 JAVA
字号:
/*
 * @(#) User.java 2007/09/01
 * 
 * Copyright 2007 HeiBei Science & Technology University
 * 
 * All rights reserved.
 */
package com.hevttc.book.template;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.Transaction;
import net.sf.hibernate.cfg.Configuration;

/**
 * 对数据库进行增,删,查,改的通用模板
 * 
 * @author linzhen
 * 
 */
public class DaoHibernateTemplate {

	public void find(ResultSession rs) {

		Configuration cfg = null;
		Session session = null;
		try {
			cfg = new Configuration().configure();
			SessionFactory sf = cfg.buildSessionFactory();
			session = sf.openSession();

			Transaction ts = session.beginTransaction();
			rs.resultSessionSet(session);
			ts.commit();

		} catch (HibernateException e) {
			e.printStackTrace();
		} finally {
			if (session != null) {
				try {
					session.close();
				} catch (HibernateException e) {
					e.printStackTrace();
				}
			}
		}
	}

}

⌨️ 快捷键说明

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