How to generate a dynamic “in (…)” sql list through Spring JdbcTemplate?

前端 未结 3 896
自闭症患者
自闭症患者 2020-12-01 06:23

Is it possible to generate arbitrary \"in ()\" lists in a SQL query through Jdbc template:

example:

\"select * from t where c in (#)\" , However \'#\' could

3条回答
  •  囚心锁ツ
    2020-12-01 06:59

    In Hibernate , you can use following sample:

    if(tenors != null && tenors.length >0)
                sql.append(" and ip.tenor_id in (:tenors)");
    
    .....
    
    
    if(tenors != null && tenors.length >0){
        query.setParameterList("tenors", tenors);                                 
    }
    .....
    SQLQuery query = (SQLQuery) getSession().createSQLQuery(sql.toString())
    

提交回复
热议问题