📄 contactpersondao.java
字号:
package com.bjsxt.crm.model;
import java.util.Date;
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.criterion.Example;
/**
* Data access object (DAO) for domain model class ContactPerson.
* @see com.bjsxt.crm.model.ContactPerson
* @author MyEclipse Persistence Tools
*/
public class ContactPersonDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(ContactPersonDAO.class);
//property constants
public static final String NAME = "name";
public static final String SEX = "sex";
public static final String GRADE = "grade";
public static final String RESPONSIBILITY = "responsibility";
public static final String TERM = "term";
public static final String TYPE = "type";
public static final String DEPARTMENT = "department";
public static final String DUTY = "duty";
public static final String OFFICE_PHONE = "officePhone";
public static final String FAX = "fax";
public static final String CELL_PHONE = "cellPhone";
public static final String EMAIL = "email";
public static final String HOME_PHONE = "homePhone";
public static final String MSN = "msn";
public static final String HOME_ADDRESS = "homeAddress";
public static final String PREFERENCE = "preference";
public static final String DESCRIPTION = "description";
public void save(ContactPerson transientInstance) {
log.debug("saving ContactPerson instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(ContactPerson persistentInstance) {
log.debug("deleting ContactPerson instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public ContactPerson findById( java.lang.Integer id) {
log.debug("getting ContactPerson instance with id: " + id);
try {
ContactPerson instance = (ContactPerson) getSession()
.get("com.bjsxt.crm.model.ContactPerson", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(ContactPerson instance) {
log.debug("finding ContactPerson instance by example");
try {
List results = getSession()
.createCriteria("com.bjsxt.crm.model.ContactPerson")
.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 ContactPerson instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from ContactPerson 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 findByName(Object name) {
return findByProperty(NAME, name);
}
public List findBySex(Object sex) {
return findByProperty(SEX, sex);
}
public List findByGrade(Object grade) {
return findByProperty(GRADE, grade);
}
public List findByResponsibility(Object responsibility) {
return findByProperty(RESPONSIBILITY, responsibility);
}
public List findByTerm(Object term) {
return findByProperty(TERM, term);
}
public List findByType(Object type) {
return findByProperty(TYPE, type);
}
public List findByDepartment(Object department) {
return findByProperty(DEPARTMENT, department);
}
public List findByDuty(Object duty) {
return findByProperty(DUTY, duty);
}
public List findByOfficePhone(Object officePhone) {
return findByProperty(OFFICE_PHONE, officePhone);
}
public List findByFax(Object fax) {
return findByProperty(FAX, fax);
}
public List findByCellPhone(Object cellPhone) {
return findByProperty(CELL_PHONE, cellPhone);
}
public List findByEmail(Object email) {
return findByProperty(EMAIL, email);
}
public List findByHomePhone(Object homePhone) {
return findByProperty(HOME_PHONE, homePhone);
}
public List findByMsn(Object msn) {
return findByProperty(MSN, msn);
}
public List findByHomeAddress(Object homeAddress) {
return findByProperty(HOME_ADDRESS, homeAddress);
}
public List findByPreference(Object preference) {
return findByProperty(PREFERENCE, preference);
}
public List findByDescription(Object description) {
return findByProperty(DESCRIPTION, description);
}
public List findAll() {
log.debug("finding all ContactPerson instances");
try {
String queryString = "from ContactPerson";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public ContactPerson merge(ContactPerson detachedInstance) {
log.debug("merging ContactPerson instance");
try {
ContactPerson result = (ContactPerson) getSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(ContactPerson instance) {
log.debug("attaching dirty ContactPerson instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(ContactPerson instance) {
log.debug("attaching clean ContactPerson instance");
try {
getSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -