Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDiego Garcia Lozano
12,503 PointsWhy users.save(students) works on the video?
Why is the method save of the UserRepository working on the video? Isn't it supposed to work for saving/updating just one User, not a list of them?
My IDE was highlighting it as an error, so I used the method saveAll instead:
users.saveAll(students);
2 Answers
ak sk
Courses Plus Student 129 Pointswhats the use of refactoring and extracting the data?
Jeremiah Shore
31,168 PointsThis is so we can perform a mutation on the review by calling the .setReviewer()
method to change the user field; it's going to be null by default. You could technically inline it with a chained call to that method, but the code's going to get harder to read.
Sometimes using an extra variable adds clarity as well. For example, in this case, we now see "reviewer" and might understand that better than if it were all chained together.
J llama
12,631 PointsI just dont see any point of adding all of the bs modulo math and retarded data for our lsit what a waste of time totally besides the point of creating a simple rest app
Andrew Menning
10,050 PointsAndrew Menning
10,050 PointsIt's likely because you are using a different version of Spring Boot. The version used in this series, 1.3.3.RELEASE, has an overloaded save method that allows either a single entity object parameter or an iterable (list) of entity objects.
If you are using 2.0.x.RELEASE, the save method is no longer overloaded and the save method only allows a single entity object as a parameter. In order to save a list of entity objects, you'll need to use the new saveAll method.