return null;
2. return (Boolean) this.getHibernateTemplate().execute(new HibernateCallback (){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
//modify by 591797 绑定SQL变量
String sql = "select cp.sfgou_flag from cdh_protocol p, cdh_cod_protocol cp "
+ " where p.protocol_id = cp.protocol_id and p.protocol_type =2 "
+ "and p.customer_code = ? ";//'"+customerCode+"'";
SQLQuery query = session.createSQLQuery(sql);
query.setParameter(0, customerCode);
List
3. return (List
@Override
public Object doInHibernate(Session session) throws HibernateException,
SQLException {
boolean flag = false; //是否有条件
// String sql = "select t.cust_id,t.bank_account,t.bank_name,"+
// " t.bank_code,t.bank_account_name,t.bank_flag,"+
// " t.account_name,c.current_department, t.customer_code,"+
// " a.billing_code,t.customer_id,c.fullname "+
// " from cdh_customer_bank t,cdh_customer c ,cdh_account a where c.customer_code(+) = t.customer_code "+
// " and a.account_id(+) = c.account_id ";
String sql = "select t.cust_id,t.bank_account,t.bank_name,t.bank_code,t.bank_account_name,"+
"t.bank_flag,t.account_name,'' current_department,t.customer_code,'' billing_code,t.customer_id," +
"'' fullname from cdh_customer_bank t Where 1=1 ";
//客户卡号
if(null != custCode && !"".equals(custCode)){
// sql += " AND T.CUSTOMER_CODE ='"+custCode.trim()+"'";
sql += " AND T.CUSTOMER_CODE = :code ";//'"+custCode.trim()+"'";
flag = true;
}
//银行名称
if(null != bankName && !"".equals(bankName)){
// sql += " AND T.BANK_NAME ='"+bankName.trim()+"'";
sql +=" AND T.BANK_NAME = :bankname ";//'"+bankName.trim()+"'";
flag = true;
}
//户名
if(null != accountName && !"".equals(accountName)){
// sql += " AND T.ACCOUNT_NAME ='"+accountName.trim()+"'";
sql += " AND T.ACCOUNT_NAME = :accountname ";//'"+accountName.trim()+"'";
flag = true;
}
//银行账号
if(null != bankAccount && !"".equals(bankAccount)){
// sql += " AND T.BANK_ACCOUNT ='"+bankAccount.trim()+"'";
sql += " AND T.BANK_ACCOUNT = :bankaccount ";//'"+bankAccount.trim()+"'";
flag = true;
}
//如果没有 任何的 查询条件 直接返回空, 目的是 防止 查询返回的数据量过大 造成内存溢出
if(!flag){
return null;
}
SQLQuery query = session.createSQLQuery(sql);
if(null != custCode && !"".equals(custCode)){
query.setParameter("code", custCode.trim());
}
//银行名称
if(null != bankName && !"".equals(bankName)){
query.setParameter("bankname", bankName.trim());
}
//户名
if(null != accountName && !"".equals(accountName)){
query.setParameter("accountname", accountName.trim());
}
//银行账号
if(null != bankAccount && !"".equals(bankAccount)){
query.setParameter("bankaccount", bankAccount.trim());
}
query = to_Type(query);//查询 返回类型 绑定
List lis = query.list();
List
for(Iterator it =lis.iterator();it.hasNext();){
Object [] obj = (Object[]) it.next();
CustomerBank cb = getCustomerBank(obj);//赋值
list.add(cb);
}
return list;
}
});
}
测试找个spring定时器,修改定时器时间,在定时器调用的函数里增加如下的入口测试:
if(true){
WebApplicationContext spring = ContextLoader.getCurrentWebApplicationContext();
//WebApplicationContext spring =WebApplicationContextUtils..getRequiredWebApplicationContext(ServletActionContext.getServletContext());
CcsCustomerReceiverDaoccsCustomerReceiverDao=(CcsCustomerReceiverDao)spring.getBean("ccsCustomerReceiverDao");
Contact contact = newContact();
contact.setName("汪先生");
contact.setCustid("7559957925");
contact.setId("7559957925002");
contact.setOp("U");
ccsCustomerReceiverDao.saveCcsCustContact(contact);
return;
}
进行修改测试。