1、选择下拉框的值,$("#id option:selected").text(),不能用$("#id").text()查询,查询结果中有别的符号
2、hibernate模板的拿到session,然后执行sql会导致多次查询之后,就查不出来了
查询语句:
String sql= "select SUM(putinNum) from Pro_putindate where goodsNo ='"+goodsNo+"' and orgId ="+orgId+" and days <="+ dayNum;
BigDecimal count;
try {
count = (BigDecimal)this.getSessionFactory().getCurrentSession().createSQLQuery(sql).list().get(0);
if(count!=null){
return count;
}
} catch (HibernateException e) {
// TODO Auto-generated catch block
return BigDecimal.ZERO;
}
这里sql没有问题。原因是你每次都执行这段话的时候都会创建一个session而这个session是不会被关掉的,因为你没关。所以多次查询就这样了。不动了
String sql= "select SUM(num) from Sales_billdetail where goodsNo ='"+goodsNo+"' and billno like '"+billno+"%' and (TO_DAYS(CURDATE()) - TO_DAYS(billdate)) <="+ dayNum;
executeBySql1(sql);
解决方法,执行完语句之后关闭session
@Override
public int executeBySql1(String sql) {
Transaction tx = null;
int count = 0;
Session session = null;
try {
session = this.sessionFactory.openSession();
tx = session.getTransaction();
session.beginTransaction();
Query query = session.createSQLQuery(sql);
count = query.executeUpdate();
tx.commit();
} catch (Exception e) {
tx.rollback();
}finally {
session.close();
}
return count;
}