Last active
September 1, 2017 11:50
-
-
Save tanapoln/4a9858f3f84eb86f6b366560a00b0821 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Transactional | |
public void updateAllFriends() { | |
Batch<Collection<User>> usersBatch = loadAllUsersBatch(); | |
for (Collection<User> users : usersBatch) { | |
for (User user : users) { | |
Collection<User> friends = fetchFriends(user); | |
TransactionUtils.requiresNewTransaction(() -> { | |
User newUser = repo.findOne(user.getId()) | |
newUser.getFriends().addAll(friends); | |
newUser.setLastUpdateTime(new Date()); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment