2017  Kodetalk | Feedback | Privacy Policy | Terms | About

Pass list of objects in NamedParameterJDBCTemplate to get results

I want to by passing List<String> of product names get a List of product details with the list that I have?

Do I iterate over the list of last names and call the getActorsWithSameLastName() everytime or does spring provide a way where it does the iteration and fetches the result for me?

Please let me know the proper solution for this.


Please find the solution here,

List<String> productNames= new ArrayList();

Map namedParameters = Collections.singletonMap("productNames", productNames);

StringBuffer recordQueryString = new StringBuffer();

recordQueryString.append("select PRODUCT_ID, PRODUCT_DESCRIPTION, PRODUCT_EXPIRED_ON from PRODUCTS where products in (:productNames) ");

List productInvolments = this.namedparameterJdbcTemplate.query(recordQueryString.toString(), namedParameters,new MyMapper());

Answer is