?? ordersdao.java
字號:
package dream.ourshopping.persistence;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import dream.ourshopping.domain.Orders;
/**
* Data access object (DAO) for domain model class Orders.
*
* @see dream.ourshopping.persistence.sqlmap.Orders
* @author MyEclipse - Hibernate Tools
*/
public class OrdersDAO extends BaseHibernateDAO {
private static Logger log = Logger.getLogger(OrdersDAO.class.getName());
// property constants
public static final String ORDERNO = "orderno";
public static final String USERID = "member";
public static final String REALNAME = "realname";
public static final String ADDRESS = "address";
public static final String ZIP = "zip";
public static final String TEL = "tel";
public static final String PAYMENT = "payment";
public static final String EMAIL = "email";
public static final String MEMO = "memo";
public static final String PRICE = "price";
public static final String TIME = "time";
public static final String TAG = "tag";
public void save(Orders transientInstance) {
log.debug("saving Orders instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Orders persistentInstance) {
log.debug("deleting Orders instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Orders findById(java.lang.Integer id) {
log.debug("getting Orders instance with id: " + id);
try {
Orders instance = (Orders) getSession().get(
"dream.ourshopping.domain.Orders", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public void updateById(java.lang.Integer id) {
log.debug("getting Orders instance with id: " + id);
try {
getSession().createQuery(
"update Orders orders set orders.tag=1 where orders.id="
+ id).executeUpdate();
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findTagByOrderno(java.lang.String orderno, java.lang.Integer tag,Integer page) {
log.debug("getting Orders instance with id: " + orderno);
try {
orderno = "'%" + orderno + "%'";
Query q = getSession().createQuery(
"from Orders orders where orders.orderno like " + orderno
+ " and orders.tag=" + tag);
q.setFirstResult(page);
q.setMaxResults(10);
List instance = q.list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findTagByOrdernoCount(java.lang.String orderno, java.lang.Integer tag) {
log.debug("getting Orders instance with id: " + orderno);
try {
orderno = "'%" + orderno + "%'";
Query q = getSession().createQuery(
"select count(*) from Orders orders where orders.orderno like " + orderno
+ " and orders.tag=" + tag);
List instance = q.list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findTagByUserid(java.lang.Integer userid) {
log.debug("getting Orders instance with id: " + userid);
try {
Query q = getSession().createQuery(
"from Orders orders where orders.member.id =" + userid);
List instance = q.list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findMaxId() {
log.debug("getting Sort instance All: ");
try {
Query q = getSession().createQuery("select max(id) from Orders ");
List instance = q.list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findListById(java.lang.Integer id) {
log.debug("getting Sort instance All: ");
try {
Query q = getSession().createQuery(
"from Orders sd where sd.tag=" + id);
List instance = q.list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findListByName(java.lang.String name) {
log.debug("getting Sort instance All: ");
try {
Query q = getSession().createQuery(
"from Orders sd where sd.tag=0 and sd.id like " + name);
List instance = q.list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Orders instance) {
log.debug("finding Orders instance by example");
try {
List results = getSession().createCriteria(
"dream.ourshopping.domain.Orders").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 Orders instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Orders 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 findByOrderno(Object orderno) {
return findByProperty(ORDERNO, orderno);
}
public List findByUserid(Object userid) {
return findByProperty(USERID, userid);
}
public List findByRealname(Object realname) {
return findByProperty(REALNAME, realname);
}
public List findByAddress(Object address) {
return findByProperty(ADDRESS, address);
}
public List findByZip(Object zip) {
return findByProperty(ZIP, zip);
}
public List findByTel(Object tel) {
return findByProperty(TEL, tel);
}
public List findByPayment(Object payment) {
return findByProperty(PAYMENT, payment);
}
public List findByEmail(Object email) {
return findByProperty(EMAIL, email);
}
public List findByMemo(Object memo) {
return findByProperty(MEMO, memo);
}
public List findByPrice(Object price) {
return findByProperty(PRICE, price);
}
public List findByTime(Object time) {
return findByProperty(TIME, time);
}
public List findByTag(Object tag) {
return findByProperty(TAG, tag);
}
public Orders merge(Orders detachedInstance) {
log.debug("merging Orders instance");
try {
Orders result = (Orders) getSession().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Orders instance) {
log.debug("attaching dirty Orders instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Orders instance) {
log.debug("attaching clean Orders 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 + -