Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
<title>DTO Query | Intro | Ebean</title>
<meta name="layout" content="_layout2/base-docs.html"/>
<meta name="bread1" content="Introduction" href="/docs/intro/"/>
<meta name="bread2" content="Queries" href="/docs/intro/queries"/>
<meta name="bread3" content="DTO query" href="/docs/intro/queries/dto-query"/>
<#assign n0_intro="active">
<#assign n1_queries="active">
<#assign dtoQuery="active">
<h2>DTO Query</h2>
We can specify the query as SQL and have that automatically mapped into DTO beans.
In typical recent applications around <code>10%</code> of queries were DTO queries.
<#include "/_common/lang-buttons.html">
<div class="code-java">
<pre content="java">
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")
<div class="code-kt">
<pre content="kotlin">
class CustomerDto {
var id: Int = 0
var name: String? = null
val beans =
DB.findDto(, "select id, name from customer where name = ?")
.setParameter(1, "Rob")
<@next_edit "SQL Query" "sql-query" "/docs/intro/queries/dto-query.html"/>