package ba.aljovic.amer.application.batch.chunk.userratings;

import ba.aljovic.amer.application.database.repositories.MovieRatingRepository;
import ba.aljovic.amer.application.database.entities.userratingsjob.MovieRating;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class MovieRatingWriter implements ItemWriter<List<MovieRating>>
{
    @Autowired
    MovieRatingRepository repository;

    @Override
    public void write(List<? extends List<MovieRating>> movieRatings) throws Exception
    {
        //movieRatings.forEach(repository::save);

        for (List<MovieRating> list : movieRatings)
        {
            for (MovieRating movieRating : list)
            {
                try
                {
                    MovieRating mr = repository.save(movieRating);
                    int a = 0;
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
        }
    }
}

@@ -601,251 +601,55 @@
     
-//movieRatings.forEach(repository::save);%0A%0A        for (List%3CMovieRating%3E list : movieRatings)%0A        %7B%0A            for (MovieRating movieRating : list)%0A            %7B%0A                try%0A                %7B%0A                    MovieRating mr = 
+try%0A        %7B%0A            movieRatings.forEach(
 repo
@@ -658,85 +658,27 @@
 tory
-.
+::
 save
-(movieRating);%0A                    int a = 0;%0A                %7D%0A        
+);%0A        %7D%0A
     
@@ -701,24 +701,16 @@
 tion e)%0A
-        
         
@@ -723,24 +723,16 @@
         
-        
 e.printS
@@ -748,40 +748,8 @@
 ();%0A
-                %7D%0A            %7D%0A
     

Fix MovieRatingsWriter