OiO.lk Blog java ParallelStrams with hibernate entity with lazy load with exception JdbcValuesSourceProcessingState
java

ParallelStrams with hibernate entity with lazy load with exception JdbcValuesSourceProcessingState


I have the entity PROJECT with the Child OUTPUS (relational @OneToMany).
In my app, i need get more tha 50000 projects by database and after get the OUTPUT information.

After get the 50000 projects, for performance, i try user the parallelStream, but when run the code, the exception is throwed: Illegal pop() with non-matching JdbcValuesSourceProcessingState

In my search, the JdbcValuesSourceProcessingState is relationed with transactionals in the hibernate.

Entity:

Can you help me?

public class Project {
@Id
private Long id;

private String name;

@OneToMany(mappedBy = "project")
private List<Output> outputs;

}

My code for get output information:

List<Project> projects = projectRepository.findAll();
    Set<SearchOutput> searchOutputs = Collections.synchronizedSet(new HashSet<>());
    projects.parallelStream().forEach(project -> {
        try {
            project.getOutputs().forEach(output->{
                SearchOutput searchOutput = new SearchOutput(project.getId(),output.getPath(),output.getName(),false);
                    searchOutputs.add(searchOutput);
            });
        } catch (Exception e) {
            LOGGER.error("ProjectID: {} - {}", project.getId(), e.getMessage());
            //throw new RuntimeException(e);

        }
    });



You need to sign in to view this answers

Exit mobile version