DTO Query

We can specify the query as SQL and have that automatically mapped into DTO beans.

In typical recent applications around 10% of queries were DTO queries.

public class CustomerDto {

  Integer id;
  String name;

  ... // getters & setters
}

List<CustomerDto> beans =
  DB.findDto(CustomerDto.class, "select id, name from customer where name = ?")
  .setParameter(1, "Rob")
  .findList();

  
class CustomerDto {

  var id: Int = 0
  var name: String? = null
}

val beans =
  DB.findDto(CustomerDto::class.java, "select id, name from customer where name = ?")
  .setParameter(1, "Rob")
  .findList()