详细异常:
could not locate named parameter [customerGroupName]; nested exception is org.hibernate.QueryParameterException: could not locate named parameter [customerGroupName]
说的很明确,不能定位到参数的位子,自己去看一下是sql上有这个字段,还是
sqlQuery.setParameter("customerGroupName", config.getCustomerGroupName());设置了这个字段,导致对不上
String sql = " update auto_order_expected_arrival_time_config set ";
if (StringUtils.isNotEmpty(config.getOrderFlag())){
sql += " orderFlag = :orderFlag,";
}
if (StringUtils.isNotEmpty(config.getDeliveryType())){
sql += " deliveryType=:deliveryType,";
}
if (StringUtils.isNotEmpty(config.getCustomerGroupId())){
sql += " customerGroupId=:customerGroupId,";
}
if (StringUtils.isNotEmpty(config.getCustomerGroupName())){
sql += " customerGroupName =:customerGroupName,";
}
if (StringUtils.isNotEmpty(config.getSupplierId())){
sql += " supplierId=:supplierId,";
}
if (StringUtils.isNotEmpty(config.getSupplierName())){
sql += " supplierName=:supplierName,";
}
if (StringUtils.isNotEmpty(config.getExpectedArrivalTime())){
sql += " expectedArrivalTime=:expectedArrivalTime,";
}
if (StringUtils.isNotEmpty(config.getCreateOper())){
sql += "createOper=:createOper,";
}
if (StringUtils.isNotEmpty(config.getOper())){
sql += " oper=:oper,";
}
if (StringUtils.isNotEmpty(config.getOpeTime())){
sql += " opeTime=:opeTime,";
}
if (Objects.nonNull(config.getDelFlag())){
sql += " delFlag=:delFlag,";
}
sql = sql.substring(0, sql.length() - 1);
sql += " where uuid = :uuid ";
SQLQuery query = (SQLQuery)sessionFactory.getCurrentSession().createSQLQuery(sql).setResultTransformer(new AliasToBeanResultTransformer(String.class));
query.setParameter("orderFlag", config.getOrderFlag());
query.setParameter("deliveryType", config.getDeliveryType());
query.setParameter("customerGroupId", config.getCustomerGroupId());
query.setParameter("customerGroupName", config.getCustomerGroupName());
query.setParameter("supplierId", config.getSupplierId());
query.setParameter("supplierName", config.getSupplierName());
query.setParameter("expectedArrivalTime", config.getExpectedArrivalTime());
query.setParameter("createOper", config.getCreateOper());
query.setParameter("createOpeTime", config.getCreateOpeTime());
query.setParameter("oper", config.getOper());
query.setParameter("opeTime", config.getOpeTime());
query.setParameter("delFlag", config.getDelFlag());
return query.executeUpdate()+"";
}
我的问题就出在这里?query.setParameter("customerGroupName", config.getCustomerGroupName());
因为上满customerGroupName可能为空,那么就没有这部分sql,但是你又来设置值.找不到这个字段
|