Created
September 1, 2017 11:51
-
-
Save tanapoln/3e08d417cb4937fcf0ae9374ef474130 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.getFriends().addAll(friends); | |
user.setLastUpdateTime(new Date()); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment