A. DML ステートメントの代わりに、allOrNone を false に設定したデータベース メソッドを使用します。
B. コレクションにレコードを追加し、これらのコレクションに対して DML 操作を実行します。
C. すべての DML 操作を future メソッド内から実行します。
D. すべての SOQL ステートメントに LIMIT 50000 を追加します。
正解:B
解説:
The most fundamental best practice for writing bulk-safe (scalable) Apex triggers is to avoid performing DML operations or SOQL queries inside of loops. Salesforce enforces a limit of 150 DML statements per transaction. If a trigger iterates through a list of 200 records and performs a delete or update inside that loop, the code will fail with a governor limit exception after the 150th record.
To make a trigger bulk-safe, developers must collect all records that need to be processed into a collection (such as a List or Map) and then perform a single DML operation on that entire collection outside of the loop ( Option B). This consumes only one DML statement regardless of the number of records (up to the 10,000 row limit).
Option A is incorrect because LIMIT 50000 does not help with bulk safety; it just prevents a query from exceeding the SOQL row limit. Option C (using allOrNone=false) allows for partial success of a DML operation but does not inherently make a trigger bulk-safe if the calls are still made inside a loop. Option D is incorrect because moving DML to a future method is a way to handle callouts or long-running processes, but it is not a general requirement for trigger bulkification and can lead to reaching asynchronous limits if used incorrectly.
正解:B
解説:
To meet the requirements specified for displaying information differently on mobile devices versus desktops and tablets, the developer needs to use Lightning Layout and Lightning Layout Item components with appropriate size attributes to control the layout based on the form factor.
Option A is correct because it sets the size attribute to "12" for desktop and tablet devices, which tells the framework to take the full width of the container, resulting in a single row. For mobile devices, it defaults to full width, which will stack the layout items vertically, resulting in three rows.
Options B, C, and D are incorrect because they either do not set the correct size attributes for desktops and tablets or do not maintain the proper structure that would result in a single row for these devices.
References:
Lightning Design System on Grid System: Lightning Grid System
Lightning Web Components Documentation on Layout Components: Layout Components
D. メソッド呼び出しを Test 内に囲みます。startbest i) および @Test_stopTast |)。
正解:C
解説:
Implementing the setFixedSearchResult= method in the test class is a way to ensure that the test class runs successfully. The setFixedSearchResult= method is a method that can be used to specify the records to be returned by the SOSL query in the test class. The setFixedSearchResult= method can accept a list of record IDs as a parameter, and return those records when the SOSL query is executed. By using the setFixedSearchResult= method, the developer can control the data returned by the SOSL query, and avoid the dependency on the data in the org. The developer can also use the Test.loadData method to load the test data from a static resource, and pass the record IDs to the setFixedSearchResult= method. For example, the developer can use the following code to implement the setFixedSearchResult= method in the test class:
// Load test data from a static resource List<sObject> testRecords = Test.loadData(Account.sObjectType, 'testData');
// Get the record IDs List<Id> recordIds = new List<Id>(); for (sObject record : testRecords) { recordIds.add(record.Id); }
// Set the fixed search result Test.setFixedSearchResults(recordIds);
// Call the method that performs the SOSL query List<Account> results = searchFeatures.search('Acme');
// Assert the expected results System.assertEquals(testRecords.size(), results.size());