日期:2014-05-17  浏览次数:20462 次

行列转换问题,sql参数注入错误

        String hql = "select c.* from (select process_date,record_id,amount from engine_fp " +
         "where legal_entity_id=:leId) s " +
         "pivot (max(amount) for process_date in([:dateFOne],[:dateFTwo])) c "+
         "where c.record_id in (select id from engine_fp_record " +
         "where sectionId <> 3)";

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("leId", leId);
        map.put("dateFOne", dateFOne);
        map.put("dateFTwo", dateFTwo);
        List<Object[]> objsList = baseHibernateDAO.findByNativeSql(hql,map);


异常:org.hibernate.exception.SQLGrammarException: Invalid parameter index 2.

leId,dateFOne,dateFTwo都有值

------解决方案--------------------
lz把参数直接写在豫剧里面能运行出想要的结果否?

如果不是传参,应该还是语句拼的有问题。