# Java apoc.periodic.iterate( {params:{...}}) insert large scale of data

**URL:** <https://community.neo4j.com/t/java-apoc-periodic-iterate-params-insert-large-scale-of-data/29082>\
**Category:** Procedures & APOC\
**Tags:** apoc, cypher, java-api, java-driver\
**Created:** [November 16, 2020, 7:57am UTC](https://community.neo4j.com/t/java-apoc-periodic-iterate-params-insert-large-scale-of-data/29082 "2020-11-16T07:57:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![boris.bakman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/boris.bakman/32/13174_2.png) [@boris.bakman](https://community.neo4j.com/u/boris.bakman)\
**Post date:** [November 16, 2020, 7:57am UTC](https://community.neo4j.com/t/java-apoc-periodic-iterate-params-insert-large-scale-of-data/29082/1 "2020-11-16T07:57:31Z")

</div>

Hi,

I'm trying to execute the following Java code with apoc without success.  
Can somebody assist me?

```auto

public interface IRelationRepository {

    @Query("call apoc.periodic.iterate("
            + "\"UNWIND $items as item return item "
            + "MERGE (s1:s{id:item.startNode.customId}) "
            + "WITH s1 "
            + "MERGE (e1:e{id:item.endNode.customId}) "
            + "MERGE (s1)-[r:item.type]->(e1) "
            + "RETURN r\", "
            + "\"SET r.id=item.customId, r.name=item.name\", "
            + "{batchSize:5000, parallel:true, iterateList:true, params:{items:$items}})")
    Result saveAll(@Param("items") List<?> items);
}

```

I also tried using:

```auto
...
            + "{batchSize:5000, parallel:true, iterateList:true, params:{items:{items}}})")
...

```

In general, what I want to do is to insert a large scale of data into Neo4j.  
The solution I found is using `apoc.periodic.iterate(...)`.  
I saw examples in which load csv/json is being used. In my case scenario, I'm building the objects in the code. So to insert those objects into a CSV file seems to be a redundant (and expensive) step.

BTW, I saw the following topic:

> [@APOC.PERIODIC.ITERATE Dynamic list iteration java/Spring](https://community.neo4j.com/t/apoc-periodic-iterate-dynamic-list-iteration-java-spring/4806):
>
> I want to pass the list that needs to be iterated and create nodes and relationships out of it. I am using Apoc.periodic.iterate now because previously i have tried with unwind which caused deadlock due to parallel execution. Help me to fix the current code section. I am processing more than 900k data in chunks. Which i will read it from kafka topics. @Query("CALL apoc.periodic.iterate("+""" + " UNWIND $items as item return item" ," + ""MERGE (src:Item {name: item.name}) " + " ON CREA…

and saw @michael.hunger replays there and in someplace over the web.  
So if you can assist, it will be fantastic.

The errors I'm receiving:

```auto
2020-11-16T10:24:43,792 ERROR [grpc-default-executor-0] i.g.i.SerializingExecutor: Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed@4950d342
java.lang.IllegalArgumentException: Infinite recursion (StackOverflowError) (through reference chain: org.orchestra.policyexplorer.data.nodes.CounterNode["countersMap"]->org.orchestra.policyexplorer.data.nodes.CounterNode["countersMap"]- ...
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3938)
	at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3879)
	a

```

Thanks in advance,  
Boris
