Skip to content

How to pass ArrayList to JPA repository method from lambda expression?

There is entity class:

public class Call {
    private String uniqId;
    private String gwNumber;

String line = "qwe-123,10nrty-345,15nasd-567,17";"n")) // "n" is used to separate data for each entity
              s-> {
                    String[] callFields =  s.split(",");  // "," is used to separate data for each filed  of entity
                    Call call = new Call();
                    List<Call> callList = new ArrayList<>();

How to pass callList to JPA repository.saveAll(callList) method ?


I think you should forget to call smth. from Steram. I do not say this is impossible, but it’s not recommended.

class Call {}

List<Call> callList ="n"))
          .map(s -> {
             Call call = new Call();
             // ...
             return call;

List<Call> callList could be written into DB.