Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
59 lines (48 sloc)
1.32 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<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"> | |
</head> | |
<body> | |
<h2>DTO Query</h2> | |
<p> | |
We can specify the query as SQL and have that automatically mapped into DTO beans. | |
</p> | |
<p> | |
In typical recent applications around <code>10%</code> of queries were DTO queries. | |
</p> | |
<#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") | |
.findList(); | |
</pre> | |
</div> | |
<div class="code-kt"> | |
<pre content="kotlin"> | |
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() | |
</pre> | |
</div> | |
<@next_edit "SQL Query" "sql-query" "/docs/intro/queries/dto-query.html"/> | |
</body> | |
</html> |