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

📄 userdao.java

📁 Spring +Web 的完整 MyEclipse 项目源码,使用者可以作为入门材料可以在此基础上深入学习
💻 JAVA
字号:
/*
 * Created on 2005-9-4
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.bid.hibernate;

import net.sf.hibernate.*;

import com.bid.domain.User;
import com.bid.exceptions.InfrastructureException;
/**
 * @author Ma Dou
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class UserDAO {

	/**
	 * 
	 */
	public UserDAO() {
		super();
		// TODO Auto-generated constructor stub
		HibernateUtil.beginTransaction();
	}
	
	public User getUserById(Long userId) throws InfrastructureException{
		//HibernateUtil.beginTransaction();
		Session session = HibernateUtil.currentSession();
		User user = null;
		try {
		user = (User) session.load(User.class, userId);
		} catch (HibernateException ex) {
			throw new InfrastructureException(ex);
		}
		return user;
		}
}

⌨️ 快捷键说明

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