No Generated SQL

This is only relevant to database operations of entity class.

Switches off generation of data access code, allowing developers to provide their own implementation.

For example, ifNo Generated SQL was set to yes for a standard read operation named myRead the generator will produce a declaration of an abstract method named myRead_da with the same signature as the formerly generated myRead method. The developer must provide the implementation of method myRead_da as is shown in the following listing:

Figure 1. Handcrafted data access implementation for a standard read
public MyEntityDtls myRead_da(
    final MyEntityKey key, final boolean forUpdate)
    throws AppException, InformationalException {

    final MyEntityDtls result = new MyEntityDtls();
    result.idNumber = "1234";
    return result;
  }

For readmulti operations - i.e. operations of stereotype readmulti, nsreadmulti, nkreadmulti or nsmulti - the handcrafted implementation must follow a different pattern. The method is declared as returning a list struct but this return value is ignored. Readmulti operations in Curam are implemented using the visitor design pattern whereby a subclass of curam.util.dataaccess.ReadmultiOperation is passed into the data access operation which then invokes its operation(Object) for each record found. Usually this operation will add the record to a collection which gets returned to the caller. This is described in greater detail in the Cúram Server Developers Guide.

The key point is that for readmulti operations, data is returned to the caller by adding it to the ReadmultiOperation class by calling its operation(Object) method, and not by simply returning it from the method. This is shown in the following example:

Figure 2. Handcrafted data access implementation for a readmulti
/*
   * This implementation returns two hard coded dummy records.
   */
  public MyEntityDtlsList readmulti_da(
    final SomeKey k, final ReadmultiOperation op,
    final boolean requireInformational)
    throws AppException, InformationalException {

    // Create and add one record for return to the caller.
    final MyEntityDtls oneDtls = new MyEntityDtls();
    oneDtls.idNumber = "2222";
    op.operation(oneDtls);

    // Create and add another record for return to the caller.
    final MyEntityDtls twoDtls = new MyEntityDtls();
    twoDtls.idNumber = "3333";
    op.operation(twoDtls);

    // our return value is ignored so just return null.
    return null;
  }