📄 userdao.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 + -