package com.zbaccp.ea.dao.impl;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.zbaccp.ea.entity.Students;
/**
* A data access object (DAO) providing persistence and search support for
* Students 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.zbaccp.ea.entity.Students
* @author MyEclipse Persistence Tools
*/
public class StudentsDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(StudentsDAO.class);
// property constants
public static final String NUMBER = "number";
public static final String NAME = "name";
public static final String SEX = "sex";
public static final String QUALIFICATION = "qualification";
public static final String TELEPHONE = "telephone";
public static final String ADDRESS = "address";
public static final String STATE = "state";
public static final String REMARK = "remark";
protected void initDao() {
// do nothing
}
public void save(Students transientInstance) {
log.debug("saving Students instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Students persistentInstance) {
log.debug("deleting Students instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Students findById(java.lang.String id) {
log.debug("getting Students instance with id: " + id);
try {
Students instance = (Students) getHibernateTemplate().get(
"com.zbaccp.ea.entity.Students", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Students instance) {
log.debug("finding Students instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
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 Students instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Students as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByNumber(Object number) {
return findByProperty(NUMBER, number);
}
public List findByName(Object name) {
return findByProperty(NAME, name);
}
public List findBySex(Object sex) {
return findByProperty(SEX, sex);
}
public List findByQualification(Object qualification) {
return findByProperty(QUALIFICATION, qualification);
}
public List findByTelephone(Object telephone) {
return findByProperty(TELEPHONE, telephone);
}
public List findByAddress(Object address) {
return findByProperty(ADDRESS, address);
}
public List findByState(Object state) {
return findByProperty(STATE, state);
}
public List findByRemark(Object remark) {
return findByProperty(REMARK, remark);
}
public List findAll() {
log.debug("finding all Students instances");
try {
String queryString = "from Students";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Students merge(Students detachedInstance) {
log.debug("merging Students instance");
try {
Students result = (Students) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Students instance) {
log.debug("attaching dirty Students instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Students instance) {
log.debug("attaching clean Students instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static StudentsDAO getFromApplicationContext(ApplicationContext ctx) {
return (StudentsDAO) ctx.getBean("StudentsDAO");
}
}