📄 customerdao.java
字号:
package com.bjsxt.crm.model;
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.hibernate.Query;
import org.hibernate.criterion.Example;
/**
* Data access object (DAO) for domain model class Customer.
* @see com.bjsxt.crm.model.Customer
* @author MyEclipse Persistence Tools
*/
public class CustomerDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(CustomerDAO.class);
//property constants
public static final String CUSTOMER_CATEGORY = "customerCategory";
public static final String NAME = "name";
public static final String SHORT_NAME = "shortName";
public static final String SN = "sn";
public static final String EVALUATION = "evaluation";
public static final String CREDIT_RATING = "creditRating";
public static final String TYPE = "type";
public static final String INDUSTRY = "industry";
public static final String RELATION_RATING = "relationRating";
public static final String SOURCE = "source";
public static final String CURRENT_STATUS = "currentStatus";
public static final String COUNTRY = "country";
public static final String PHONE = "phone";
public static final String PROVINCE = "province";
public static final String FAX = "fax";
public static final String CITY = "city";
public static final String SITE = "site";
public static final String POSTCODE = "postcode";
public static final String ADDRESS = "address";
public static final String DESCRIPTION = "description";
public static final String SHARED = "shared";
public static final String EMPLOYEE_SIZE = "employeeSize";
public static final String SEX = "sex";
public void save(Customer transientInstance) {
log.debug("saving Customer instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Customer persistentInstance) {
log.debug("deleting Customer instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Customer findById( java.lang.Integer id) {
log.debug("getting Customer instance with id: " + id);
try {
Customer instance = (Customer) getSession()
.get("com.bjsxt.crm.model.Customer", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Customer instance) {
log.debug("finding Customer instance by example");
try {
List results = getSession()
.createCriteria("com.bjsxt.crm.model.Customer")
.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 Customer instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Customer 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 findByCustomerCategory(Object customerCategory) {
return findByProperty(CUSTOMER_CATEGORY, customerCategory);
}
public List findByName(Object name) {
return findByProperty(NAME, name);
}
public List findByShortName(Object shortName) {
return findByProperty(SHORT_NAME, shortName);
}
public List findBySn(Object sn) {
return findByProperty(SN, sn);
}
public List findByEvaluation(Object evaluation) {
return findByProperty(EVALUATION, evaluation);
}
public List findByCreditRating(Object creditRating) {
return findByProperty(CREDIT_RATING, creditRating);
}
public List findByType(Object type) {
return findByProperty(TYPE, type);
}
public List findByIndustry(Object industry) {
return findByProperty(INDUSTRY, industry);
}
public List findByRelationRating(Object relationRating) {
return findByProperty(RELATION_RATING, relationRating);
}
public List findBySource(Object source) {
return findByProperty(SOURCE, source);
}
public List findByCurrentStatus(Object currentStatus) {
return findByProperty(CURRENT_STATUS, currentStatus);
}
public List findByCountry(Object country) {
return findByProperty(COUNTRY, country);
}
public List findByPhone(Object phone) {
return findByProperty(PHONE, phone);
}
public List findByProvince(Object province) {
return findByProperty(PROVINCE, province);
}
public List findByFax(Object fax) {
return findByProperty(FAX, fax);
}
public List findByCity(Object city) {
return findByProperty(CITY, city);
}
public List findBySite(Object site) {
return findByProperty(SITE, site);
}
public List findByPostcode(Object postcode) {
return findByProperty(POSTCODE, postcode);
}
public List findByAddress(Object address) {
return findByProperty(ADDRESS, address);
}
public List findByDescription(Object description) {
return findByProperty(DESCRIPTION, description);
}
public List findByShared(Object shared) {
return findByProperty(SHARED, shared);
}
public List findByEmployeeSize(Object employeeSize) {
return findByProperty(EMPLOYEE_SIZE, employeeSize);
}
public List findBySex(Object sex) {
return findByProperty(SEX, sex);
}
public List findAll() {
log.debug("finding all Customer instances");
try {
String queryString = "from Customer";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Customer merge(Customer detachedInstance) {
log.debug("merging Customer instance");
try {
Customer result = (Customer) getSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Customer instance) {
log.debug("attaching dirty Customer instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Customer instance) {
log.debug("attaching clean Customer 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 + -