/**
* A data access object (DAO) providing persistence and search support for
* Examinee entities. Transaction control of the save(), update() and delete()
* operations can directly support Spring container-managed transactions or they
* can be augmented to handle user-managed Spring transactions. Each of these
* methods provides additional information for how to configure it for the
* desired type of transaction control.
*
* @see com.hepeng.events.Examinee
* @author MyEclipse Persistence Tools
*/
public class ExamineeDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(ExamineeDAO.class);
// property constants
public static final String IDENTITY_CARD_ID = "identityCardId";
public static final String CERTIFICATE_ID = "certificateId";
public static final String NAME = "name";
public static final String DEPARTMENT = "department";
public static final String SEX = "sex";
public static final String AGE = "age";
public static final String PHOTO = "photo";
public List findByExample(Examinee instance) {
log.debug("finding Examinee instance by example");
try {
List results = getSession().createCriteria(
"com.hepeng.events.Examinee").add(Example.create(instance))
.list();
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding Examinee instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Examinee as model where model."
+ propertyName + "= ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByIdentityCardId(Object identityCardId) {
return findByProperty(IDENTITY_CARD_ID, identityCardId);
}
public List findByCertificateId(Object certificateId) {
return findByProperty(CERTIFICATE_ID, certificateId);
}
public List findByName(Object name) {
return findByProperty(NAME, name);
}
public List findByDepartment(Object department) {
return findByProperty(DEPARTMENT, department);
}
public List findBySex(Object sex) {
return findByProperty(SEX, sex);
}
public List findByAge(Object age) {
return findByProperty(AGE, age);
}
//其实没有这个需求
public List findByPhoto(Object photo) {
return findByProperty(PHOTO, photo);
}
public List findAll() {
log.debug("finding all Examinee instances");
try {
String queryString = "from Examinee";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}