"Call in transactions" subquery with APOC is working but Calling Custom procedure and using "Call in transactions" resulted in Exception. "Expected transaction state to be empty when calling transactional subquery. (Transactions committed: 0)"

Hi Team,

i have run the apoc procedure with call in transactions working fine. below is the Query

:auto
match (ent:EntityDefinitions{entityName : "T_PROCESS"})-[:hasEntityRecord]->(rec:EntityRecord) with rec,ent limit 2
CALL apoc.refactor.cloneNodes([rec]) YIELD input,output
CALL { WITH output,ent MERGE (ent)-[:hasEntityRecord]->(output) return ID(output) as m} IN TRANSACTIONS OF 10000 ROWS return m limit 1

But if we copy the same codes from apoc git hub and created a custom proceduure plugin its resulted in Error

:auto match(n:Sequence{nflowsId : 1669035509347}) with n limit 1
CALL rule.procedure.cloneNodes([n]) YIELD input,output
CALL { WITH output MERGE (ent:EntityDefinitions{entityName : "T_PROCESS"})-[:hasEntityRecord]->(output) return ID(output) as m} IN TRANSACTIONS OF 10000 ROWS return m limit 1

this is Error
Neo.DatabaseError.Statement.ExecutionFailed

Expected transaction state to be empty when calling transactional subquery. (Transactions committed: 0)

Wonder why the same procedure runs with the combination of APOC and Call in Transactions but it throws error if we use custom procedure and Call in Transactions
the procedure code same java code from apoc repo.

My java Version - JDK 15
Neo4j Version 4.4.7

Procedure Plugin

 @Procedure(name = "rule.procedure.cloneNodes", mode = Mode.WRITE)
	    @Description("Clones the given nodes with their labels and properties.\n" +
	            "It is possible to skip any node properties using skipProperties (note: this only skips properties on nodes and not their relationships).")
	    public Stream<NodeRefactorResult> cloneNodes(@Name("nodes") List<Node> nodes,
	                                                 @Name(value = "withRelationships", defaultValue = "false") boolean withRelationships,
	                                                 @Name(value = "skipProperties", defaultValue = "[]") List<String> skipProperties) {
	        return doCloneNodes(nodes, withRelationships, skipProperties);
	    }
	
	 private Stream<NodeRefactorResult> doCloneNodes(@Name("nodes") List<Node> nodes, @Name("withRelationships") boolean withRelationships, List<String> skipProperties) {
	        if (nodes == null) return Stream.empty();
	        return nodes.stream().map(node -> Util.rebind(tx, 
  node.getProperty("nflowsId").toString()) ).map(node -> {
	            NodeRefactorResult result = new NodeRefactorResult(node.getId());
	            try {
	                Node copy = Util.withTransactionAndRebind(db, tx,  transaction -> {
	                    Node newNode = copyLabels(node, tx.createNode());

	                    Map<String, Object> properties = node.getAllProperties();
	                    if (skipProperties != null && !skipProperties.isEmpty())
	                        for (String skip : skipProperties) properties.remove(skip);

	                    newNode = copyProperties(properties, newNode);
	                    copyLabels(node, newNode);
	                    return newNode;
	                });
	               
	                return result.withOther(copy);
	            } catch (Exception e) {
	                return result.withError(e);
	            }
	        });
	    }```

public static T withTransactionAndRebind(GraphDatabaseService db, Transaction transaction, Function<Transaction, T> action) {
T result = retryInTx(NullLog.getInstance(), db, action, 0, 0, r -> {});
return rebind(transaction, result);
}

public static <T> T retryInTx(Log log, GraphDatabaseService db, Function<Transaction, T> function, long retry, long maxRetries, Consumer<Long> callbackForRetry) {
    try (Transaction tx = db.beginTx()) {
        T result = function.apply(tx);
        tx.commit();
        return result;
    } catch (Exception e) {
        if (retry >= maxRetries) throw e;
        if (log!=null) {
            log.warn("Retrying operation %d of %d", retry, maxRetries);
        }
        callbackForRetry.accept(retry);
        Util.sleep(100);
        return retryInTx(log, db, function, retry + 1, maxRetries, callbackForRetry);
    }
}
Please help me.