81,092
社区成员
发帖
与我相关
我的任务
分享
/**
* 得到一个对象,根据ID
* @param clazz
* @param id
* @return
*/
public Object get(Class clazz, Serializable id) {
try {
Object item = getSession().get(clazz, id);
return item;
} catch (RuntimeException re) {
throw re;
}finally {
HibernateSessionFactory.closeSession();
}
}
/**
* @param args
*/
public static void main(String[] args) {
BaseDaoHbm bHbm = new BaseDaoHbm();
Member member = (Member) bHbm.get(Member.class, 1);
System.out.println(member.getUserId());
}