Is it possible to generate arbitrary “in ()” lists in a SQL query through Jdbc template:
example:
“select * from t where c in (#)” , However ‘#’ could be an arbitrary list of values only known at runtime.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, it’s possible in Spring if you use
NamedParameterJdbcTemplateorSimpleJdbcTemplatewith named parameters. List parameter can be set as ajava.util.List:In this case Spring internally creates the SQL query with the required number of placeholders based on the size of the actual list when replacing named parameters with
?s.