legacy-knowledge-base
公開されました Jul. 2, 2025

ユーザーを一括で削除するGroovyスクリプトのメソッド

written-by

Kenny Back

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • Liferayインスタンスから一度に多くのユーザーを、データベースを直接修正することなく、プログラム的かつ効率的な方法で削除する必要があります(これは推奨されません)。

環境

  • DXP 7.1

解像度

  • 以下は、ユーザーを一括で削除するための、実行可能な動的クエリーを利用したgroovyスクリプトのテンプレートです。
import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
import com.liferay.portal.kernel.service.UserLocalServiceUtil;
import com.liferay.portal.kernel.model.User;

ActionableDynamicQuery adq = UserLocalServiceUtil.getActionableDynamicQuery();

adq.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<User>() {

@Override
public void performAction(User user) {
out.println(user);
}

});

try {
adq.performActions();
}
catch (Exception e) {
e.printStackTrace();
}
  • さらに、スクリプトを低環境でテストし、本番で実行する前にデータベースをバックアップすることをお勧めします。
  • Groovy Scriptsについてさらにサポートが必要な場合は、 Global Services オプションについて、カスタマーサクセス担当者にお気軽にお問い合わせください。

追加情報

did-this-article-resolve-your-issue

legacy-knowledge-base