title: How can I pass a collection as Spring Batch JobParameter?
body: <p>I wanted to pass the collection of String as a step parameter.
  Since I didn't find a way to construct <code>JobParameter</code> for collection, I decided to pass it as a string with comma-separated values.</p>
  <p>My code to execute the job:</p>
  <pre><code>@Autowired
  private JobLauncher jobLauncher;
  @Autowired
  private Job myJob;
  
  public void execute() {
      List&lt;String&gt; myCollection = getMyCollection();
      
      jobLauncher.run(myJob, new JobParameters(ImmutableMap.&lt;String, JobParameter&gt; builder()
              .put(&quot;myCollection&quot;, new JobParameter(String.join(&quot;,&quot;, myCollection)))
              .build())
      ...
  }
  </code></pre>
  <p>I define the Step as follows:</p>
  <pre><code>@Bean
  @StepScope
  public Step myStep(@Value(&quot;#{jobParameters['myCollection']}&quot;) String myCollectionString) {
      List&lt;String&gt; myCollection = ArrayUtil.asList(lisReferencesString.split(&quot;,&quot;));
      ...
  }
  </code></pre>
  <p>But when execution is started I'm getting the error:</p>
  <pre><code>org.postgresql.util.PSQLException: ERROR: value too long for type character varying(250)
  </code></pre>
  <p>Since the job params are stored as a column value, I can't pass too long strings as a param.</p>
  <p>Could you suggest how I could overcome it?</p>