Using Record Not Found Indicator

Each of the singleton reads of the database (entity read, nsread, nkread operations) which could potentially throw a RecordNotFoundException has overloads added to take a Record Not Found Indicator variable.

The reasons for providing a Record Not Found Indicator are:

This indicator (curam.util.type.NotFoundIndicator) wraps a boolean value which indicates whether the required record could not be found. When this indicator is passed into one of the above read operations, the operation will never throw a RecordNotFoundException if the record does not exist but will instead set the boolean flag inside NotFoundIndicator to true, and return a value of null. If the record is found, the boolean flag inside NotFoundIndicator is set to false, and the record is returned.

Whenever a developer wishes to pass a NotFoundIndicator into a singleton read operation, it is always passed in as the first argument. This is shown in the following examples:

Figure 1. A typical read operation which may throw a RecordNotFoundException
try {
  bankAccountDtls = bankAccount.read(bankAccountKey);
} catch (RecordNotFoundException rnf) {
  // record was not found...
}
Figure 2. The overloaded version of the one above, using the NotFoundIndicator
final NotFoundIndicator notFoundInd =
  new curam.util.type.NotFoundIndicator();
bankAccountDtls = bankAccount.read(notFoundInd, bankAccountKey);
if (notFoundInd.isNotFound()) {
  // record was not found...
} else {
  // record was found...
}
Figure 3. A typical read operation for update which may throw a RecordNotFoundException
try {
  bankAccountDtls = bankAccount.read(bankAccountKey, true);
} catch (RecordNotFoundException rnf) {
  // record was not found...
}
Figure 4. The overloaded version of the one above, using the NotFoundIndicator
bankAccountDtls =
  bankAccount.read(notFoundInd, bankAccountKey, true);
if (notFoundInd.isNotFound()) {
  // record was not found...
} else {
  // record was found...
}