hibernate访问数据库的几种方式
来源:互联网 发布:js获取id值 编辑:程序博客网 时间:2024/06/10 05:08
package com.carInsur.model.dao;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.carInsur.model.CarInsurOrderCarInfo;
import com.carInsur.model.PeopleSend;
import com.carInsur.model.T33CarinsuranceOrder;
import com.carInsur.model.T33CarinsuranceOrderlog;
import org.springframework.orm.hibernate3.HibernateTemplate;
import com.model.system.TBrchMng;
public class CarInsurOrderCarInfoDAO extends HibernateDaoSupport {
private static final Log log = LogFactory
.getLog(CarInsurOrderCarInfoDAO.class);
public List<String> findCustomerInfo(String ownerID, String carID) {
try {
Session session = getHibernateTemplate().getSessionFactory()
.getCurrentSession();
if (carID == null)
return null;
if (carID.length() == 0)
return null;
if (ownerID == null)
return null;
if (ownerID.length() == 0)
return null;
String queryString = "";
queryString = "select t1.name, t1.mobile from customerQT t1where t1.shenfenID = '"
+ ownerID + "' and t1.carNum = '" + carID + "'";
System.out.println(queryString);
Query query = session.createQuery(queryString);
List result = query.list();
List list = new ArrayList();
Iterator it = result.iterator();
int tableSeq = 1;
while (it.hasNext()) {
Object[] object = (Object[]) it.next();
String name = (String) object[0];
String mobile = (String) object[1];
if(name != null)
list.add(name);
if(mobile != null)
list.add(mobile);
}
return list;
} catch (RuntimeException re) {
log.error("查询用户信息失败", re);
// log.error("find by property name failed", re);
throw re;
}
}
public List<CarInsurOrderCarInfo> findOrderCarInfo(String brchNo,
String sDate, String eDate, String carID, String statusInput,
String companyNo, String codeNo) {
try {
Session session = getHibernateTemplate().getSessionFactory()
.getCurrentSession();
if(carID == null)
carID = "-";
if(carID.length() == 0)
carID = "-";
/*
* String queryString =
* "select t1.orderid,t1.companyid,t1.carnumber,t1.payamt,t2.companyName from T33CarinsuranceOrder as t1,"
* + "T33CarinsuranceCompany as t2 where t1.txnbranch='" + brchNo +
* "' and t1.orderstatus='02' and t1.companyid=t2.companyId";
*/
// String queryString =
// "select t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.compreappno, t.commerceappno, t.datezhifu, t1.shenfenID from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2 where t.carnumber = t1.carNum and t.companyid = t2.company_id ";
// 如果codeNo=1说明是录入支付,或者是保单确认
String queryString = "";
if (codeNo.equals("1"))
queryString = "select t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.comprehensiveid, t.commercialid, t.datezhifu, t1.shenfenID from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2 where t1.shenfenID = t.ownerid and t1.carNum = t.carnumber and t.companyid = t2.company_id and t.companyid = '"
+ companyNo
+ "' and ((t.carnumber = '"
+ carID
+ "') or ('"
+ carID
+ "' = '-')) and t.orderstatus in ('05', '06')and ((t.datezhifu between '"
+ sDate
+ "' and '"
+ eDate
+ "') or (t.dateshoukuan between '"
+ sDate
+ "' and '"
+ eDate
+ "')) and (t.txnbranch in (select t6.brchNo from TBrchMng t6 where t6.counBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t7.brchNo from TBrchMng t7 where t7.cityBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t8.brchNo from TBrchMng t8 where t8.provBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t9.brchNo from TBrchMng t9 where t9.brchNo = '"
+ brchNo + "'))";
// 2说明是手工补录保单
if (codeNo.equals("2")) {
queryString = "select t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.comprehensiveid, t.commercialid, t.datezhifu, t1.shenfenID from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2 where t1.shenfenID = t.ownerid and t1.carNum = t.carnumber and t.companyid = t2.company_id and t.companyid = '"
+ companyNo
+ "' and ((t.carnumber = '"
+ carID
+ "') or ('"
+ carID
+ "' = '-')) and t.orderstatus in ('06')and ((t.datezhifu between '"
+ sDate
+ "' and '"
+ eDate
+ "') ) and (t.txnbranch in (select t6.brchNo from TBrchMng t6 where t6.counBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t7.brchNo from TBrchMng t7 where t7.cityBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t8.brchNo from TBrchMng t8 where t8.provBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t9.brchNo from TBrchMng t9 where t9.brchNo = '"
+ brchNo + "'))";
}
// 3打印配送信息
if (codeNo.equals("3"))
queryString = "select distinct t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.comprehensiveid, t.commercialid, t.datezhifu, t1.shenfenID, t3.pkgName, t3.pkgId, t4.recipienttelephone, t4.recipientadress, t.member_id from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2, T33CarinsuranceGift t3, PeopleSend t4 where t1.shenfenID = t.ownerid and t1.carNum = t.carnumber and t.companyid = t2.company_id and t.companyid = '"
+ companyNo
+ "' and t.packid = t3.pkgId and t.orderid = t4.orderid and ((t.carnumber = '"
+ carID
+ "') or ('"
+ carID
+ "' = '-')) and t.orderstatus in ('07', '08')and ((t.datehedui between '"
+ sDate
+ "' and '"
+ eDate
+ "') or (t.datepeisong between '"
+ sDate
+ "' and '"
+ eDate
+ "')) and (t.txnbranch in (select t6.brchNo from TBrchMng t6 where t6.counBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t7.brchNo from TBrchMng t7 where t7.cityBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t8.brchNo from TBrchMng t8 where t8.provBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t9.brchNo from TBrchMng t9 where t9.brchNo = '"
+ brchNo + "'))";
//录入完结
if (codeNo.equals("4"))
queryString = "select distinct t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.comprehensiveid, t.commercialid, t.datezhifu, t1.shenfenID, t3.pkgName, t3.pkgId, t4.recipienttelephone, t4.recipientadress, t.member_id from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2, T33CarinsuranceGift t3, PeopleSend t4 where t1.shenfenID = t.ownerid and t1.carNum = t.carnumber and t.companyid = t2.company_id and t.companyid = '"
+ companyNo
+ "' and t.packid = t3.pkgId and t.orderid = t4.orderid and ((t.carnumber = '"
+ carID
+ "') or ('"
+ carID
+ "' = '-')) and t.orderstatus in ('09', '08')and ((t.datewanjie between '"
+ sDate
+ "' and '"
+ eDate
+ "') or (t.datepeisong between '"
+ sDate
+ "' and '"
+ eDate
+ "')) and (t.txnbranch in (select t6.brchNo from TBrchMng t6 where t6.counBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t7.brchNo from TBrchMng t7 where t7.cityBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t8.brchNo from TBrchMng t8 where t8.provBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t9.brchNo from TBrchMng t9 where t9.brchNo = '"
+ brchNo + "'))";
/*
* private String applicantmobile; private String recipientadress;
* private String PKG_NAME; private String productId;
*/
System.out.println(queryString);
Query query = session.createQuery(queryString);
List result = query.list();
List list = new ArrayList();
// List list = new LinkedList();
Iterator it = result.iterator();
int tableSeq = 1;
while (it.hasNext()) {
// System.out.println("into while");
CarInsurOrderCarInfo rowinfo = new CarInsurOrderCarInfo();
Object[] object = (Object[]) it.next();
String seq1 = (String) object[0];
String orderid = (String) object[1];
String status = (String) object[2];
String ownerName = (String) object[3];
String carnumber = (String) object[4];
String companyid = (String) object[5];
String company_name = (String) object[6];
String compreappno = (String) object[7];
String commerceappno = (String) object[8];
String datezhifu = (String) object[9];
String ownerID = (String) object[10];
rowinfo.setTableSeq(tableSeq);
rowinfo.setSeq1(seq1);
rowinfo.setStatus(status);
rowinfo.setOrderid(orderid);
rowinfo.setOwnerID(ownerID);
rowinfo.setOwnerName(ownerName);
rowinfo.setCarnumber(carnumber);
rowinfo.setCompanyid(companyid);
rowinfo.setCompany_name(company_name);
rowinfo.setCompreappno(compreappno);
rowinfo.setCommerceappno(commerceappno);
rowinfo.setDatezhifu(datezhifu);
if (codeNo.equals("3") || codeNo.equals("4")) {// t3.pkgName, t3.pkgId,
// t4.recipienttelephone,
// t4.recipientadress
String applicantmobile = (String) object[13];
String recipientadress = (String) object[14];
String member_id = (String) object[15];
String PKG_NAME = (String) object[11];
Long lPkgId = (Long) object[12];
String pkgId = "";
if (lPkgId != null)
pkgId = lPkgId.toString();
rowinfo.setApplicantmobile(applicantmobile);
rowinfo.setRecipientadress(recipientadress);
rowinfo.setPKG_NAME(PKG_NAME);
rowinfo.setPkgId(pkgId);
rowinfo.setMember_id(member_id);
}
tableSeq++;
list.add(rowinfo);
}
/*
* System.out.println("ssssssssssssssssssssssssssssssssssssss"); for
* (int i = 0; i < list.size(); i++) { CarInsurOrderCarInfo tem =
* (CarInsurOrderCarInfo) list.get(i);
* System.out.println(tem.getTableSeq()); }
* System.out.println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
*/
return list;
} catch (RuntimeException re) {
log.error("查询订单和车辆信息失败", re);
// log.error("find by property name failed", re);
throw re;
}
}
public boolean updateOrderInfo(T33CarinsuranceOrder order) {
try {
getHibernateTemplate().setFlushMode(HibernateTemplate.FLUSH_EAGER);
System.out.println("updateOrderInfo = " + order.getOrderid());
getHibernateTemplate().update(order);
return true;
} catch (Exception re) {
log.error("更新记录操作数据库失败!", re);
return false;
// throw re;
}
}
public List<T33CarinsuranceOrder> getOrderInfo(String orderID) {
try {
// T33CarinsuranceOrder orderTem = new T33CarinsuranceOrder();
System.out.println("getOrderInfo = " + orderID);
orderID = orderID.trim();
// getHibernateTemplate().setFlushMode(HibernateTemplate.FLUSH_EAGER);
String queryString = "from T33CarinsuranceOrder as model where model.orderid='"
+ orderID + "'";
System.out.println(queryString);
List<T33CarinsuranceOrder> list = getHibernateTemplate().find(
queryString);
return list;
} catch (RuntimeException re) {
log.error("查询订单信息失败", re);
throw re;
}
}
public List<PeopleSend> getPeopleSendInfo(String orderID) {
try {
// T33CarinsuranceOrder orderTem = new T33CarinsuranceOrder();
System.out.println("getPeopleSendInfo = " + orderID);
orderID = orderID.trim();
// getHibernateTemplate().setFlushMode(HibernateTemplate.FLUSH_EAGER);
String queryString = "from PeopleSend as model where model.orderid='"
+ orderID + "'";
System.out.println(queryString);
List<PeopleSend> list = getHibernateTemplate().find(queryString);
return list;
} catch (RuntimeException re) {
log.error("查询订单信息失败", re);
throw re;
}
}
public boolean insertLog(T33CarinsuranceOrderlog logInfo) {
try {
System.out.println(logInfo.getTxnbranch()
+ " b********************** " + logInfo.getOrderid()
+ " " + logInfo.getSeqNo() + " "
+ logInfo.getTxndate());
getHibernateTemplate().setFlushMode(HibernateTemplate.FLUSH_EAGER);
getHibernateTemplate().save(logInfo);//.saveOrUpdate(logInfo);
return true;
} catch (Exception re) {
log.error("插入日志失败!", re);
//System.out.println(re.getStackTrace());
re.printStackTrace();
return false;
// throw re;
}
}
}
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.carInsur.model.CarInsurOrderCarInfo;
import com.carInsur.model.PeopleSend;
import com.carInsur.model.T33CarinsuranceOrder;
import com.carInsur.model.T33CarinsuranceOrderlog;
import org.springframework.orm.hibernate3.HibernateTemplate;
import com.model.system.TBrchMng;
public class CarInsurOrderCarInfoDAO extends HibernateDaoSupport {
private static final Log log = LogFactory
.getLog(CarInsurOrderCarInfoDAO.class);
public List<String> findCustomerInfo(String ownerID, String carID) {
try {
Session session = getHibernateTemplate().getSessionFactory()
.getCurrentSession();
if (carID == null)
return null;
if (carID.length() == 0)
return null;
if (ownerID == null)
return null;
if (ownerID.length() == 0)
return null;
String queryString = "";
queryString = "select t1.name, t1.mobile from customerQT t1where t1.shenfenID = '"
+ ownerID + "' and t1.carNum = '" + carID + "'";
System.out.println(queryString);
Query query = session.createQuery(queryString);
List result = query.list();
List list = new ArrayList();
Iterator it = result.iterator();
int tableSeq = 1;
while (it.hasNext()) {
Object[] object = (Object[]) it.next();
String name = (String) object[0];
String mobile = (String) object[1];
if(name != null)
list.add(name);
if(mobile != null)
list.add(mobile);
}
return list;
} catch (RuntimeException re) {
log.error("查询用户信息失败", re);
// log.error("find by property name failed", re);
throw re;
}
}
public List<CarInsurOrderCarInfo> findOrderCarInfo(String brchNo,
String sDate, String eDate, String carID, String statusInput,
String companyNo, String codeNo) {
try {
Session session = getHibernateTemplate().getSessionFactory()
.getCurrentSession();
if(carID == null)
carID = "-";
if(carID.length() == 0)
carID = "-";
/*
* String queryString =
* "select t1.orderid,t1.companyid,t1.carnumber,t1.payamt,t2.companyName from T33CarinsuranceOrder as t1,"
* + "T33CarinsuranceCompany as t2 where t1.txnbranch='" + brchNo +
* "' and t1.orderstatus='02' and t1.companyid=t2.companyId";
*/
// String queryString =
// "select t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.compreappno, t.commerceappno, t.datezhifu, t1.shenfenID from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2 where t.carnumber = t1.carNum and t.companyid = t2.company_id ";
// 如果codeNo=1说明是录入支付,或者是保单确认
String queryString = "";
if (codeNo.equals("1"))
queryString = "select t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.comprehensiveid, t.commercialid, t.datezhifu, t1.shenfenID from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2 where t1.shenfenID = t.ownerid and t1.carNum = t.carnumber and t.companyid = t2.company_id and t.companyid = '"
+ companyNo
+ "' and ((t.carnumber = '"
+ carID
+ "') or ('"
+ carID
+ "' = '-')) and t.orderstatus in ('05', '06')and ((t.datezhifu between '"
+ sDate
+ "' and '"
+ eDate
+ "') or (t.dateshoukuan between '"
+ sDate
+ "' and '"
+ eDate
+ "')) and (t.txnbranch in (select t6.brchNo from TBrchMng t6 where t6.counBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t7.brchNo from TBrchMng t7 where t7.cityBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t8.brchNo from TBrchMng t8 where t8.provBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t9.brchNo from TBrchMng t9 where t9.brchNo = '"
+ brchNo + "'))";
// 2说明是手工补录保单
if (codeNo.equals("2")) {
queryString = "select t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.comprehensiveid, t.commercialid, t.datezhifu, t1.shenfenID from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2 where t1.shenfenID = t.ownerid and t1.carNum = t.carnumber and t.companyid = t2.company_id and t.companyid = '"
+ companyNo
+ "' and ((t.carnumber = '"
+ carID
+ "') or ('"
+ carID
+ "' = '-')) and t.orderstatus in ('06')and ((t.datezhifu between '"
+ sDate
+ "' and '"
+ eDate
+ "') ) and (t.txnbranch in (select t6.brchNo from TBrchMng t6 where t6.counBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t7.brchNo from TBrchMng t7 where t7.cityBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t8.brchNo from TBrchMng t8 where t8.provBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t9.brchNo from TBrchMng t9 where t9.brchNo = '"
+ brchNo + "'))";
}
// 3打印配送信息
if (codeNo.equals("3"))
queryString = "select distinct t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.comprehensiveid, t.commercialid, t.datezhifu, t1.shenfenID, t3.pkgName, t3.pkgId, t4.recipienttelephone, t4.recipientadress, t.member_id from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2, T33CarinsuranceGift t3, PeopleSend t4 where t1.shenfenID = t.ownerid and t1.carNum = t.carnumber and t.companyid = t2.company_id and t.companyid = '"
+ companyNo
+ "' and t.packid = t3.pkgId and t.orderid = t4.orderid and ((t.carnumber = '"
+ carID
+ "') or ('"
+ carID
+ "' = '-')) and t.orderstatus in ('07', '08')and ((t.datehedui between '"
+ sDate
+ "' and '"
+ eDate
+ "') or (t.datepeisong between '"
+ sDate
+ "' and '"
+ eDate
+ "')) and (t.txnbranch in (select t6.brchNo from TBrchMng t6 where t6.counBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t7.brchNo from TBrchMng t7 where t7.cityBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t8.brchNo from TBrchMng t8 where t8.provBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t9.brchNo from TBrchMng t9 where t9.brchNo = '"
+ brchNo + "'))";
//录入完结
if (codeNo.equals("4"))
queryString = "select distinct t.seq1, t.orderid, t.orderstatus, t1.name, t.carnumber, t.companyid, t2.company_name, t.comprehensiveid, t.commercialid, t.datezhifu, t1.shenfenID, t3.pkgName, t3.pkgId, t4.recipienttelephone, t4.recipientadress, t.member_id from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2, T33CarinsuranceGift t3, PeopleSend t4 where t1.shenfenID = t.ownerid and t1.carNum = t.carnumber and t.companyid = t2.company_id and t.companyid = '"
+ companyNo
+ "' and t.packid = t3.pkgId and t.orderid = t4.orderid and ((t.carnumber = '"
+ carID
+ "') or ('"
+ carID
+ "' = '-')) and t.orderstatus in ('09', '08')and ((t.datewanjie between '"
+ sDate
+ "' and '"
+ eDate
+ "') or (t.datepeisong between '"
+ sDate
+ "' and '"
+ eDate
+ "')) and (t.txnbranch in (select t6.brchNo from TBrchMng t6 where t6.counBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t7.brchNo from TBrchMng t7 where t7.cityBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t8.brchNo from TBrchMng t8 where t8.provBrch = '"
+ brchNo
+ "') or t.txnbranch in (select t9.brchNo from TBrchMng t9 where t9.brchNo = '"
+ brchNo + "'))";
/*
* private String applicantmobile; private String recipientadress;
* private String PKG_NAME; private String productId;
*/
System.out.println(queryString);
Query query = session.createQuery(queryString);
List result = query.list();
List list = new ArrayList();
// List list = new LinkedList();
Iterator it = result.iterator();
int tableSeq = 1;
while (it.hasNext()) {
// System.out.println("into while");
CarInsurOrderCarInfo rowinfo = new CarInsurOrderCarInfo();
Object[] object = (Object[]) it.next();
String seq1 = (String) object[0];
String orderid = (String) object[1];
String status = (String) object[2];
String ownerName = (String) object[3];
String carnumber = (String) object[4];
String companyid = (String) object[5];
String company_name = (String) object[6];
String compreappno = (String) object[7];
String commerceappno = (String) object[8];
String datezhifu = (String) object[9];
String ownerID = (String) object[10];
rowinfo.setTableSeq(tableSeq);
rowinfo.setSeq1(seq1);
rowinfo.setStatus(status);
rowinfo.setOrderid(orderid);
rowinfo.setOwnerID(ownerID);
rowinfo.setOwnerName(ownerName);
rowinfo.setCarnumber(carnumber);
rowinfo.setCompanyid(companyid);
rowinfo.setCompany_name(company_name);
rowinfo.setCompreappno(compreappno);
rowinfo.setCommerceappno(commerceappno);
rowinfo.setDatezhifu(datezhifu);
if (codeNo.equals("3") || codeNo.equals("4")) {// t3.pkgName, t3.pkgId,
// t4.recipienttelephone,
// t4.recipientadress
String applicantmobile = (String) object[13];
String recipientadress = (String) object[14];
String member_id = (String) object[15];
String PKG_NAME = (String) object[11];
Long lPkgId = (Long) object[12];
String pkgId = "";
if (lPkgId != null)
pkgId = lPkgId.toString();
rowinfo.setApplicantmobile(applicantmobile);
rowinfo.setRecipientadress(recipientadress);
rowinfo.setPKG_NAME(PKG_NAME);
rowinfo.setPkgId(pkgId);
rowinfo.setMember_id(member_id);
}
tableSeq++;
list.add(rowinfo);
}
/*
* System.out.println("ssssssssssssssssssssssssssssssssssssss"); for
* (int i = 0; i < list.size(); i++) { CarInsurOrderCarInfo tem =
* (CarInsurOrderCarInfo) list.get(i);
* System.out.println(tem.getTableSeq()); }
* System.out.println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
*/
return list;
} catch (RuntimeException re) {
log.error("查询订单和车辆信息失败", re);
// log.error("find by property name failed", re);
throw re;
}
}
public boolean updateOrderInfo(T33CarinsuranceOrder order) {
try {
getHibernateTemplate().setFlushMode(HibernateTemplate.FLUSH_EAGER);
System.out.println("updateOrderInfo = " + order.getOrderid());
getHibernateTemplate().update(order);
return true;
} catch (Exception re) {
log.error("更新记录操作数据库失败!", re);
return false;
// throw re;
}
}
public List<T33CarinsuranceOrder> getOrderInfo(String orderID) {
try {
// T33CarinsuranceOrder orderTem = new T33CarinsuranceOrder();
System.out.println("getOrderInfo = " + orderID);
orderID = orderID.trim();
// getHibernateTemplate().setFlushMode(HibernateTemplate.FLUSH_EAGER);
String queryString = "from T33CarinsuranceOrder as model where model.orderid='"
+ orderID + "'";
System.out.println(queryString);
List<T33CarinsuranceOrder> list = getHibernateTemplate().find(
queryString);
return list;
} catch (RuntimeException re) {
log.error("查询订单信息失败", re);
throw re;
}
}
public List<PeopleSend> getPeopleSendInfo(String orderID) {
try {
// T33CarinsuranceOrder orderTem = new T33CarinsuranceOrder();
System.out.println("getPeopleSendInfo = " + orderID);
orderID = orderID.trim();
// getHibernateTemplate().setFlushMode(HibernateTemplate.FLUSH_EAGER);
String queryString = "from PeopleSend as model where model.orderid='"
+ orderID + "'";
System.out.println(queryString);
List<PeopleSend> list = getHibernateTemplate().find(queryString);
return list;
} catch (RuntimeException re) {
log.error("查询订单信息失败", re);
throw re;
}
}
public boolean insertLog(T33CarinsuranceOrderlog logInfo) {
try {
System.out.println(logInfo.getTxnbranch()
+ " b********************** " + logInfo.getOrderid()
+ " " + logInfo.getSeqNo() + " "
+ logInfo.getTxndate());
getHibernateTemplate().setFlushMode(HibernateTemplate.FLUSH_EAGER);
getHibernateTemplate().save(logInfo);//.saveOrUpdate(logInfo);
return true;
} catch (Exception re) {
log.error("插入日志失败!", re);
//System.out.println(re.getStackTrace());
re.printStackTrace();
return false;
// throw re;
}
}
}
0 0
- hibernate访问数据库的几种方式
- 数据库访问表的几种方式
- .net中访问oracle数据库的几种方式
- ASP.net中访问数据库的几种方式
- .net中访问oracle数据库的几种方式
- .net中访问oracle数据库的几种方式
- hibernate访问数据库方式
- 在Hibernate里面动态切换SChema实现访问不同的数据库的几种方法
- 在Hibernate里面动态切换SChema实现访问不同的数据库的几种方法
- 在Hibernate里面动态切换SChema实现访问不同的数据库的几种方法
- 在Hibernate里面动态切换SChema实现访问不同的数据库的几种方法
- spring+hibernate架构中Dao访问数据库的几种方法
- spring+hibernate架设中Dao访问数据库的几种步骤
- spring+hibernate架构中Dao访问数据库的几种方法
- spring+hibernate架构中Dao访问数据库的几种方法
- spring+hibernate架构中Dao访问数据库的几种方法
- spring+hibernate架构中Dao访问数据库的几种方法
- Ajax访问服务器的几种方式
- JDBC 时间问题
- linux文件共享(samba)
- c++中double转换成string型(浮点数的格式化)
- [持续更新]我有特别的C++技巧之拷贝赋值操作符
- myeclipse包的层数和package的层数不一致
- hibernate访问数据库的几种方式
- 康托展开
- 网络设备集线器、交换机、路由器的理解
- 解读 Java 三大框架 独家播出
- 在Ubuntu 12.04 桌面上设置启动器(快捷方式)过程讲解:
- Android Framework 记录之一
- javascript 特性检测并非浏览器检测
- linux安装Mysql
- Bitmap的recycle问题