In Guidewire InsuranceSuite, developers frequently need to " reach across " one-to-many relationships to collect data from nested arrays. In this scenario, the goal is to retrieve a flattened list of all Note entities associated with all Policy objects linked to a specific Account.
According to Advanced Gosu best practices, the most efficient and idiomatic way to handle this is by using the Expansion Operator (*). As shown in Option B, the syntax account.Policies*.Notes performs what is known as " collection flattening. " When the expansion operator is applied to the Policies array, Gosu understands that it should look at every policy in that collection and access the Notes array for each. It then automatically flattens these multiple sub-collections into a single, comprehensive list of Note objects. Calling .toList() at the end ensures the result is captured in a standard, manipulatable collection format.
This approach is vastly superior to nested for loops (Option C). Manual iteration through nested arrays is a primary cause of the " N+1 " query problem and " Bundle Bloat. " In nested loops, the system may perform a separate database fetch for every policy and then another for every note, loading every single entity into the current transaction bundle, which consumes excessive memory and CPU time. The expansion operator, however, is highly optimized within the Gosu Runtime to handle these traversals more gracefully.
Option D is incorrect because it uses a second expansion operator to retrieve the DisplayName property, resulting in a list of Strings rather than a list of Note entities. Option A, while using the Query API, is logically disconnected from the root account object already in memory and represents a more complex search-based approach rather than a relationship-based retrieval. Therefore, the expansion operator is the verified standard for efficient, readable data collection in Gosu.
==========
Submit