Skip to content

Commit

Permalink
LPD-X Avoid the cacheless DynamicQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
shuyangzhou committed May 11, 2024
1 parent 77ae292 commit ea15858
Showing 1 changed file with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import com.liferay.account.model.AccountEntryUserRel;
import com.liferay.account.service.AccountEntryUserRelLocalService;
import com.liferay.petra.string.StringPool;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.User;
Expand All @@ -18,7 +16,6 @@
import com.liferay.portal.search.spi.model.index.contributor.ModelDocumentContributor;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.osgi.service.component.annotations.Component;
Expand Down Expand Up @@ -56,16 +53,10 @@ public void contribute(Document document, User user) {
protected long[] getAccountEntryIds(User user) throws Exception {
Set<Long> accountEntryIds = new HashSet<>();

DynamicQuery dynamicQuery =
accountEntryUserRelLocalService.dynamicQuery();
for (AccountEntryUserRel accountEntryUserRel :
accountEntryUserRelLocalService.
getAccountEntryUserRelsByAccountUserId(user.getUserId())) {

dynamicQuery.add(
RestrictionsFactoryUtil.eq("accountUserId", user.getUserId()));

List<AccountEntryUserRel> accountEntryUserRels =
accountEntryUserRelLocalService.dynamicQuery(dynamicQuery);

for (AccountEntryUserRel accountEntryUserRel : accountEntryUserRels) {
accountEntryIds.add(accountEntryUserRel.getAccountEntryId());
}

Expand Down

0 comments on commit ea15858

Please sign in to comment.