In Guidewire InsuranceSuite,Bundle Managementis the core mechanism for managing database transactions. When you retrieve an entity via a query, as seen in the code sample, that entity is inread-onlymode. To modify it and persist those changes, the entity must be associated with aBundle.
1. Adding the Entity to the Bundle (Option D)
The code sample retrieves a company object, but it is currently "read-only" because it was fetched outside of the newBundle context. To make the entity editable, you must explicitly add it to the bundle using the add() method:
Code snippet
company = newBundle.add(company)
company.Notes = "TBD"
By adding the entity to the bundle, Gosu creates a "writable" clone of the object. Any changes made to the properties of this specific instance are tracked by the bundle. Without this step, setting company.Notes = "TBD" would result in a runtime exception stating that the entity is read-only.
2. Committing the Changes (Option A)
A bundle acts as a temporary "staging area" for changes. Simply modifying an object within a bundle does not automatically update the database. To persist the data, the developer must explicitly call thecommitmethod:
Code snippet
newBundle.commit()
This triggers the database transaction, executing the necessary SQL UPDATE statements and clearing the bundle's state upon success.
Why other options are incorrect:*Option Edescribes the syntax for a runWithNewBundle block. While using runWithNewBundle is considered a best practice because it handles the commit and exception logic automatically, the question specifically asks what needs to be changed in theprovidedprocedural code.
Option B and Care incorrect because you do not add "Notes" (a property) or a "Query" object to a bundle; you only addEntitiesthat you intend to modify or create.