Which is best way update the record in liferay?Which is best way update the record in liferay?https://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=834714882024-03-29T09:41:39Z2024-03-29T09:41:39ZRE: Which is best way update the record in liferay?Andrew Jardinehttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=835655592016-12-14T21:57:21Z2016-12-14T21:57:21ZIs this a one time operation? Is it is then I would just go with number two... It'll take less time to run that it would to find a "optimised solution". If you are going to be doing 100 record updates regularly though, I would donasnhas been suggested -- try to do batches of 10 - 20 ... That way if one or two fail, it won't affect the entire set of records.Andrew Jardine2016-12-14T21:57:21ZRE: Which is best way update the record in liferay?Ricardo Vieirahttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=835565352016-12-14T17:14:11Z2016-12-14T17:14:11ZIn my opinion you should query the db for the 100 records, update them and save all in batch, if anything goes wrong, just rollback, or do it in batches, in case someday there will be more then 100, like 20 at the time, just need to work on the query. <br /><br />and then create the new ones. <br /><br />If you remove the 100 and create them again, they won't be the same records, they will have new id's, so that's not a good solution in my view.Ricardo Vieira2016-12-14T17:14:11ZWhich is best way update the record in liferay?Montej Shahhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=834714872016-12-13T05:43:12Z2016-12-13T05:43:12ZHi All,<br />I have created the Table named <strong>Subject</strong>. Which contain the below field.<br />subjectPrimaryKey<br />subjectName<br />subjectValue<br />countryInformationId<br /><br />Now I have scenario where I need to update the 100 of records in the bunch(also add 2 or 3 new subject) where the <strong>countryInformationId</strong> is same.<br /><br />I have two solution for that.<br /><strong>First One</strong><br /><blockquote>//remove all the 100 records.<br />SubjectUtil.removeByCountryInformationId(countryInformationId);<br />//add the 100 records as new ( which are need to update) and also other new records.<br />for(...){<br />subjectLocalService<br /> .createSubject(CounterLocalServiceUtil<br /> .increment(Subject.class.getName()));<br />..<br />..<br />subjectLocalService.update(subject);<br />}</blockquote><br /><br /><strong>Second One</strong><br /><blockquote>//iterate over all the sujbect<br />for(...){<br /> //Get individual record by the subject id <br /> subjectLocalService.getSubject(subjectId);<br /> //Update record and save it.<br /> ....<br /> subjectLocalService.update(subject);<br />}<br />//add new records which are not exist in database.<br /> for(...){<br />subjectLocalService<br /> .createSubject(CounterLocalServiceUtil<br /> .increment(Subject.class.getName()));<br />..<br />..<br />subjectLocalService.update(subject);<br />}</blockquote>&l