?? studao.java
字號(hào):
package org.hj.impdao;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import org.apache.commons.beanutils.BeanUtils;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hj.intdao.IStuDao;
import org.hj.pojos.Student;
import org.hj.vo.VOStudent;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class StuDao extends HibernateDaoSupport implements IStuDao {
/**
* 添加方法
*/
public Student regist(VOStudent v) {
final Student stu=new Student();
try {
BeanUtils.copyProperties(stu, v);//賦值,由struts提s供的
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
Object obj=super.getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session) throws HibernateException, SQLException {
session.setFlushMode(FlushMode.AUTO);
getHibernateTemplate().save(stu);
session.flush();
return stu;
}
});
return (Student)obj;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -