📄 hoteldetailinfodao.java
字号:
package com.woyi.dao;
// default package
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
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.Session;
import org.hibernate.Transaction;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.woyi.dto.HotelDetailInfo;
import com.woyi.page.PageInfo;
import com.woyi.page.Pagination;
/**
* Data access object (DAO) for domain model class HotelDetailInfo.
* @see .HotelDetailInfo
* @author MyEclipse Persistence Tools
*/
public class HotelDetailInfoDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(HotelDetailInfoDAO.class);
//property constants
public static final String HOTELS_ID = "hotelsId";
public static final String CLUB_ID = "clubId";
public static final String HOTELNAME = "hotelname";
public static final String HOTELSTATUS = "hotelstatus";
public static final String OPTRID = "optrid";
public static final String CUSTID = "custid";
public static final String CUSTNAME = "custname";
public static final String CUSTCERTID = "custcertid";
public static final String CUSTPHONE = "custphone";
public static final String CUSTTYPE = "custtype";
public static final String REMARK = "remark";
private Pagination pageInfo;
public Pagination getPageInfo() {
return pageInfo;
}
public void setPageInfo(Pagination pageInfo) {
this.pageInfo = pageInfo;
}
protected void initDao() {
//do nothing
}
public boolean save(HotelDetailInfo transientInstance) {
log.debug("saving HotelInfo instance");
boolean isflag = false;
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
isflag = true;
return isflag;
} catch (RuntimeException re) {
log.error("save failed", re);
return isflag;
}
}
public boolean delete(HotelDetailInfo persistentInstance) {
log.debug("deleting HotelDetailInfo instance");
boolean isflag = false;
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
isflag = true;
return isflag;
} catch (RuntimeException re) {
log.error("delete failed", re);
return isflag;
}
}
/**
* Method 删除客房、包间预订执行删除
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public boolean deleteHotelDetailby(int hotelDetailInfo,String query) {
boolean isflag = false;
Session session = getHibernateTemplate().getSessionFactory().openSession();
Transaction ts=session.beginTransaction();
Connection conn=session.connection();
int i=0;
try {
Statement state=conn.createStatement();
if ("0".equals(query)){
i=state.executeUpdate("delete from t_info_hotelsdetail where Hotels_id= "+hotelDetailInfo);
}else if ("1".equals(query)){
i=state.executeUpdate("delete from t_info_roomsdetail where Rooms_id= "+hotelDetailInfo);
}else{
i=state.executeUpdate("delete from t_info_hotelsdetail where Club_id= "+hotelDetailInfo);
i=state.executeUpdate("delete from t_info_roomsdetail where Club_id= "+hotelDetailInfo);
}
if(i==0){
isflag=false;
}
isflag = true;
} catch (SQLException re) {
session.close();
re.printStackTrace();
}
ts.commit();
session.close();
return isflag;
}
public HotelDetailInfo findById( java.lang.Integer id) {
log.debug("getting HotelDetailInfo instance with id: " + id);
try {
HotelDetailInfo instance = (HotelDetailInfo) getHibernateTemplate()
.get("HotelDetailInfo", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(HotelDetailInfo instance) {
log.debug("finding HotelDetailInfo 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 HotelDetailInfo instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from HotelDetailInfo 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 findByHotelsId(Object hotelsId) {
return findByProperty(HOTELS_ID, hotelsId);
}
public List findByClubId(Object clubId) {
return findByProperty(CLUB_ID, clubId);
}
public List findByHotelname(Object hotelname) {
return findByProperty(HOTELNAME, hotelname);
}
public List findByHotelstatus(Object hotelstatus) {
return findByProperty(HOTELSTATUS, hotelstatus);
}
public List findByOptrid(Object optrid) {
return findByProperty(OPTRID, optrid);
}
public List findByCustid(Object custid) {
return findByProperty(CUSTID, custid);
}
public List findByCustname(Object custname) {
return findByProperty(CUSTNAME, custname);
}
public List findByCustcertid(Object custcertid) {
return findByProperty(CUSTCERTID, custcertid);
}
public List findByCustphone(Object custphone) {
return findByProperty(CUSTPHONE, custphone);
}
public List findByCusttype(Object custtype) {
return findByProperty(CUSTTYPE, custtype);
}
public List findByRemark(Object remark) {
return findByProperty(REMARK, remark);
}
public List findAll() {
log.debug("finding all HotelDetailInfo instances");
try {
String queryString = "from HotelDetailInfo";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public HotelDetailInfo merge(HotelDetailInfo detachedInstance) {
log.debug("merging HotelDetailInfo instance");
try {
HotelDetailInfo result = (HotelDetailInfo) getHibernateTemplate()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public boolean attachDirty(HotelDetailInfo instance) {
log.debug("attaching dirty HotelInfo instance");
boolean isflag = false;
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
isflag = true;
return isflag;
} catch (RuntimeException re) {
log.error("attach failed", re);
return isflag;
}
}
public void attachClean(HotelDetailInfo instance) {
log.debug("attaching clean HotelDetailInfo instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
/**
* 查询客房预订信息
* @param propertyName
* @param value
* @return
*/
public List findHotelDetailInfo(Integer hotelsId) {
try {
String queryString = "from HotelDetailInfo as model where model.hotelsId="
+ hotelsId+" and model.hotelstatus != 0";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
/**
* 查询单个客房预订信息
* @param propertyName
* @param value
* @return
*/
public List findSingleHotelDetailInfo(Integer hotelsDetailId) {
try {
String queryString = "from HotelDetailInfo as model where model.hotelsDetailId="
+ hotelsDetailId+" and model.hotelstatus != '0'";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
/**
* 查询客房提醒
* @param propertyName
* @param value
* @return
*/
public PageInfo queryHOrderalert(int pageno) {
PageInfo pageInfo1 = null;
try {
String queryString = "from HotelDetailInfo as model where model.endtime <="
+"'"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+"'";
String queryString1 = "select count(model) from HotelDetailInfo as model where model.endtime <="
+"'"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+"'";
pageInfo1 = pageInfo.page(pageno,10,queryString,queryString1);
return pageInfo1;
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public static HotelDetailInfoDAO getFromApplicationContext(ApplicationContext ctx) {
return (HotelDetailInfoDAO) ctx.getBean("HotelDetailInfoDAO");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -