package cn.myexam.model;
import cn.myexam.hibernate.BaseHibernateDAO;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Transaction;
import org.hibernate.criterion.Example;
public class StudentDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(StudentDAO.class);
public static final String STU_ID = "stuId";
public static final String PASSWORD = "password";
public static final String NAME = "name";
public static final String SEX = "sex";
public static final String TEL = "tel";
public static final String ADDRESS = "address";
public static final String EMAIL = "email";
public static final String TYPE = "type";
public boolean save(Student transientInstance) {
log.debug("saving Student instance");
boolean passed = false;
try {
Transaction tx = getSession().beginTransaction();
getSession().save(transientInstance);
tx.commit();
log.debug("save successful");
passed = true;
} catch (RuntimeException re) {
log.error("save failed", re);
passed = false;
throw re;
}finally{
closeSession();
}
return passed;
}
public boolean delete(Student persistentInstance) {
log.debug("deleting Student instance");
boolean passed = false;
try {
Transaction tx = getSession().beginTransaction();
getSession().delete(persistentInstance);
tx.commit();
log.debug("delete successful");
passed = true;
} catch (RuntimeException re) {
log.error("delete failed", re);