import java.util.Calendar;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import org.hibernate.Criteria;
import org.hibernate.criterion.Expression;
/**
* Data access object (DAO) for domain model class Transactionheaders.
*
* @see com.xpedx.commissions.commission.persist.Transactionheaders
* @author MyEclipse Persistence Tools
*/
public class TransactionheadersDAO extends BaseHibernateDAO {
private static final Log log = LogFactory
.getLog(TransactionheadersDAO.class);
// property constants
public static final String ID_1 = "id_1";
public static final String CUSTSALESREP = "custsalesrep";
public static final String SALESREPUSED = "salesrepused";
public static final String CUSTOMERNUMBER = "customernumber";
public static final String CUSTOMERNAME = "customername";
public static final String HEADERCOMMISSIONAMT = "headercommissionamt";
public void save(Transactionheaders transientInstance) {
log.debug("saving Transactionheaders instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Transactionheaders persistentInstance) {
log.debug("deleting Transactionheaders instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Transactionheaders findById( com.xpedx.commissions.commission.persist.TransactionheadersId id) { log.debug("getting Transactionheaders instance with id: " + id); Transactionheaders instance = null; try { instance = (Transactionheaders) getSession() .get( "com.xpedx.commissions.commission.persist.Transactionheaders", id); } catch (HibernateException e){ log.error("Exception" + e.getMessage()); } return instance; }
public List findByExample(Transactionheaders instance) {
log.debug("finding Transactionheaders instance by example");
try {
List results = getSession()
.createCriteria(
"com.xpedx.commissions.commission.persist.Transactionheaders")
.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 Transactionheaders instance with property: "
+ propertyName + ", value: " + value);
try {
String queryString = "from Transactionheaders 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 getAllHeaders() {
Calendar cal = Calendar.getInstance();
cal.set(2007, 05, 01);
Calendar cal2 = Calendar.getInstance();
cal2.set(2007, 01, 01);
Criteria criteria = getSession().createCriteria(Transactionheaders.class);
criteria.add(Expression.ge("date",cal2.getTime()));
criteria.add(Expression.le("date",cal.getTime()));
List results = criteria.list();
return results;
}
public List findById_1(Object id_1) {
return findByProperty(ID_1, id_1);
}
public List findByCustsalesrep(Object custsalesrep) {
return findByProperty(CUSTSALESREP, custsalesrep);
}
public List findBySalesrepused(Object salesrepused) {
return findByProperty(SALESREPUSED, salesrepused);
}
public List findByCustomernumber(Object customernumber) {
return findByProperty(CUSTOMERNUMBER, customernumber);
}
public List findByCustomername(Object customername) {
return findByProperty(CUSTOMERNAME, customername);
}
public List findByHeadercommissionamt(Object headercommissionamt) {
return findByProperty(HEADERCOMMISSIONAMT, headercommissionamt);
}
public List findAll() {
log.debug("finding all Transactionheaders instances");
try {
String queryString = "from Transactionheaders";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Transactionheaders merge(Transactionheaders detachedInstance) {
log.debug("merging Transactionheaders instance");
try {
Transactionheaders result = (Transactionheaders) getSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Transactionheaders instance) {
log.debug("attaching dirty Transactionheaders instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Transactionheaders instance) {
log.debug("attaching clean Transactionheaders instance");
try {
getSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
}
generated using myeclipse.
|