package com.tcs.hrr.dao;
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.tcs.hrr.domain.Candidate;
/**
* A data access object (DAO) providing persistence and search support for
* Candidate 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.tcs.hrr.domain.Candidate
* @author MyEclipse Persistence Tools
*/
public class CandidateDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(CandidateDAO.class);
// property constants
public static final String NAME = "name";
public static final String PINYIN = "pinyin";
public static final String EMAIL = "email";
public static final String CANDIDATE_TYPE = "candidateType";
public static final String TWE = "twe";
public static final String RWE = "rwe";
public static final String GRADE = "grade";
public static final String ENGLISH_LEVEL = "englishLevel";
public static final String CONTACT_NO = "contactNo";
public static final String CUR_LOCATION = "curLocation";
public static final String EMP_STATUS = "empStatus";
public static final String WORK_LOCATION = "workLocation";
public static final String TAG_OWNER_ID = "tagOwnerId";
public static final String CUR_SALARY = "curSalary";
public static final String EXP_SALARY = "expSalary";
public static final String REMARK = "remark";
public static final String PROPOSE_STATUS = "proposeStatus";
public static final String CALLER = "caller";
public static final String CREATE_BY = "createBy";
public static final String UPDATE_BY = "updateBy";
public static final String STATUS = "status";
protected void initDao() {
// do nothing
}
public void save(Candidate transientInstance) {
log.debug("saving Candidate instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Candidate persistentInstance) {
log.debug("deleting Candidate instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Candidate findById(java.lang.Integer id) {
log.debug("getting Candidate instance with id: " + id);
try {
Candidate instance = (Candidate) getHibernateTemplate().get(
"com.tcs.hrr.domain.Candidate", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Candidate instance) {
log.debug("finding Candidate 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 Candidate instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Candidate 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 findByName(Object name) {
return findByProperty(NAME, name);
}
public List findByPinyin(Object pinyin) {
return findByProperty(PINYIN, pinyin);
}
public List findByEmail(Object email) {
return findByProperty(EMAIL, email);
}
public List findByCandidateType(Object candidateType) {
return findByProperty(CANDIDATE_TYPE, candidateType);
}
public List findByTwe(Object twe) {
return findByProperty(TWE, twe);
}
public List findByRwe(Object rwe) {
return findByProperty(RWE, rwe);
}
public List findByGrade(Object grade) {
return findByProperty(GRADE, grade);
}
public List findByEnglishLevel(Object englishLevel) {
return findByProperty(ENGLISH_LEVEL, englishLevel);
}
public List findByContactNo(Object contactNo) {
return findByProperty(CONTACT_NO, contactNo);
}
public List findByCurLocation(Object curLocation) {
return findByProperty(CUR_LOCATION, curLocation);
}
public List findByEmpStatus(Object empStatus) {
return findByProperty(EMP_STATUS, empStatus);
}
public List findByWorkLocation(Object workLocation) {
return findByProperty(WORK_LOCATION, workLocation);
}
public List findByTagOwnerId(Object tagOwnerId) {
return findByProperty(TAG_OWNER_ID, tagOwnerId);
}
public List findByCurSalary(Object curSalary) {
return findByProperty(CUR_SALARY, curSalary);
}
public List findByExpSalary(Object expSalary) {
return findByProperty(EXP_SALARY, expSalary);
}
public List findByRemark(Object remark) {
return findByProperty(REMARK, remark);
}
public List findByProposeStatus(Object proposeStatus) {
return findByProperty(PROPOSE_STATUS, proposeStatus);
}
public List findByCaller(Object caller) {
return findByProperty(CALLER, caller);
}
public List findByCreateBy(Object createBy) {
return findByProperty(CREATE_BY, createBy);
}
public List findByUpdateBy(Object updateBy) {
return findByProperty(UPDATE_BY, updateBy);
}
public List findByStatus(Object status) {
return findByProperty(STATUS, status);
}
public List findAll() {
log.debug("finding all Candidate instances");
try {
String queryString = "from Candidate";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Candidate merge(Candidate detachedInstance) {
log.debug("merging Candidate instance");
try {
Candidate result = (Candidate) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Candidate instance) {
log.debug("attaching dirty Candidate instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Candidate instance) {
log.debug("attaching clean Candidate instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static CandidateDAO getFromApplicationContext(ApplicationContext ctx) {
return (CandidateDAO) ctx.getBean("CandidateDAO");
}
}