waiterinfodaoimpl.java
来自「酒店管理系统 用sh编写的酒店管理系统 毕业设计用的」· Java 代码 · 共 161 行
JAVA
161 行
package com.chen.interFace.InterFaceDAO;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.chen.hibernate.hsf.HibernateSessionFactory;
import com.chen.interFace.WaiterinfoDAO;
import com.chen.modle.allroomDAO.Allroominfo;
public class WaiterinfoDAOImpl implements WaiterinfoDAO {
Transaction ts = null;
public boolean waiterlogin(String waitername, String password) {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Waiterinfo w where w.waitername='"+waitername+"' and w.waiterpassword='"+password+"'";
Query query = session.createQuery(str);
if(query.list()!=null&&query.list().size()>0)
{return true;}
}catch (HibernateException e) {
e.printStackTrace();
} finally {
HibernateSessionFactory.closeSession();
}
return false;
}
public List selectWaiterinfo(String waitername) {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Waiterinfo w where w.waitername='"+waitername+"'";
Query query = session.createQuery(str);
return query.list();
}catch (HibernateException e) {
e.printStackTrace();
} finally {
HibernateSessionFactory.closeSession();
}
return null;
}
public List selectAllReserveroom() {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Roomreserveinfo r";
Query query = session.createQuery(str);
return query.list();
}catch (HibernateException e) {
e.printStackTrace();
} finally {
HibernateSessionFactory.closeSession();
}
return null;
}
public List selectReserveroom(String name) {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Roomreserveinfo r where r.reservername='"+name+"'";
Query query = session.createQuery(str);
return query.list();
}catch (HibernateException e) {
e.printStackTrace();
} finally {
HibernateSessionFactory.closeSession();
}
return null;
}
public List selectReserveroombynum(int roomid) {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Roomreserveinfo r where r.roomid='"+roomid+"'";
Query query = session.createQuery(str);
return query.list();
}catch (HibernateException e) {
e.printStackTrace();
} finally {
HibernateSessionFactory.closeSession();
}
return null;
}
public List selectAllroombynum(int roomnumber) {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Allroominfo a where a.roomnumber='"+roomnumber+"'";
Query query = session.createQuery(str);
return query.list();
}catch (HibernateException e) {
e.printStackTrace();
} finally {
HibernateSessionFactory.closeSession();
}
return null;
}
public int getAllroomidbynum(int roomnumber) {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Allroominfo a where a.roomnumber='"+roomnumber+"'";
Query query = session.createQuery(str);
Allroominfo allroominfo = (Allroominfo) query.list().get(0);
return allroominfo.getRoomid();
}catch (HibernateException e) {
e.printStackTrace();
}
return 0;
}
public List selectAllroombyid(int roomid) {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Allroominfo a where a.roomid='"+roomid+"'";
Query query = session.createQuery(str);
//Allroominfo allroominfo = (Allroominfo) query.list().get(0);
return query.list();
}catch (HibernateException e) {
e.printStackTrace();
}
return null;
}
public List selectStayedrooms() {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Roomstayedinfo r";
Query query = session.createQuery(str);
//Allroominfo allroominfo = (Allroominfo) query.list().get(0);
return query.list();
}catch (HibernateException e) {
e.printStackTrace();
}
return null;
}
public List selectStayedroombynum(int roomnumber) {
try{
Session session = HibernateSessionFactory.getSession();
String str = "from Roomstayedinfo r where r.roomnumber='"+roomnumber+"'";
Query query = session.createQuery(str);
//Allroominfo allroominfo = (Allroominfo) query.list().get(0);
return query.list();
}catch (HibernateException e) {
e.printStackTrace();
}
return null;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?