We are trying to insert about 100k users in Liferay. Is there a way to have this all updated in one batch commit, instead of making separate calls to add each user?
Asked
Active
Viewed 889 times
2 Answers
5
It think yes it's possible.
Build a custom remote service entity like BulkUserServiceUtil.addUsers
, within it call the standard method UserLocalServiceUtil.addUser
for each user.
Returning from the BulkUserServiceUtil
method the transaction is committed.

Daniele Baggio
- 2,157
- 1
- 14
- 21
-
3+1 for going the service way. *Do not* use SQL inserts: Don't *ever* write to the database using SQL, because Liferay needs more than just what's obvious in the user table. This warning is missing, otherwise I'd fully support this answer. – Olaf Kock Nov 04 '15 at 12:04
-3
@sandeep:
Yes, Liferay not provide us to add/update bulk users, because after user creation some table affected in that and also user indexed, but if you want to do that I have two suggestions :
- Take a reference of REINDEX option of articles: in that case you can create a batch of counter range with some sort of value and update/add that batch, but the thing is Liferay internally call addUser default. So its iterative way which you can use.
- Without Service : Create some custom script and directly hit the DB for once. which create users but in that case you have to take care of other liferay tables which need to be insert the userID or respective data.

Ashish Dadhich
- 4,737
- 4
- 17
- 25
-
2Sorry but "Create some custom script and directly hit the DB for once" is possible but it is a very bad habit for liferay. – Daniele Baggio Nov 04 '15 at 10:14
-
calling 100k times iteration best you can write some sort code which not hitting DB that much. If Liferay not allow then we've to do something different. – Ashish Dadhich Nov 04 '15 at 10:22