CINXE.COM
Ebean ORM for Java & Kotlin
<!doctype html> <html lang="en"> <head> <title>Ebean ORM for Java & Kotlin</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="shortcut icon" href="/images/favicon.ico"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Source+Sans+Pro|Ubuntu&display=swap"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous"> <link rel="stylesheet" href="/css/reset3.css"> <link rel="stylesheet" href="/css/site3.css"> <link rel="stylesheet" href="/css/pygments3.css"> <meta http-equiv="X-UA-Compatible" content="ie-edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div id="main"> <div id="banner"> <header> <nav id="top"> <ul> <li><a href="/"><span class="fas fa-home"></span> Home</a></li> <li><a href="/docs">Docs</a></li> <li><a href="/docs/getting-started">Get Started</a></li> <li><a href="/support">Help</a></li> <li><a href="/videos">Videos</a></li> <li><a target="_blank" href="/apidoc/13">ApiDocs</a></li> <li><a href="/releases">Releases</a></li> <li><a href="https://github.com/ebean-orm/ebean" title="github source"><i class="fab fa-github"></i></a></li> <li><a onclick="toggleTheme();" title="switch dark light theme"><i class="fas fa-adjust"></i></a></li> </ul> </nav> </header> </div> <article id="home-article"> <section> <h3>Search documentation</h3> <div id="nav-search"> <form action="https://www.google.com/search" method="get" class="inline-form"> <input type="hidden" name="as_sitesearch" value="ebean.io"> <div id="page-search"> <div class="input-group"> <input class="frm" name="q" id="searchinput" type="text" placeholder="Search... (press 's' to focus)" data-placeholder-focus="Search... (use '↑', '↓' and '⏎' to select results)" data-placeholder-blur="Search... (press 's' to focus)" autocomplete="off"> <div class="input-group-btn"> <button class="frm" type="submit"><i class="fas fa-search"></i></button> </div> </div> <div id="page-search-results" style="display: none;"> <ul id="search-results-container" class="search-results"><li class=" active"><a href="/docs" title="Docs"><span style="color:#777;">Docs</span> Documentation </a></li><li class=""><small style="color:#999;">And 101 more...</small></li></ul> </div> </div> </form> </div> </section> <div id="hero"> <h1><img src="/images/logo-200.png" width="120"> Ebean ORM</h1> <h2>Persistence for Java & Kotlin</h2> <div class="links"> <h4><a class="bright-link" href="/docs/getting-started"><i class="fas fa-angle-right"></i> Getting started</a></h4> <h4><a href="/docs"><i class="fas fa-angle-right"></i> Documentation</a></h4> <h4><a href="https://github.com/ebean-orm"><i class="fas fa-angle-right"></i> Github</a></h4> </div> <div id="sponsors"> <h4 class="mtx"><a href="/sponsors">premium sponsors</a></h4> <a class="sponsor" href="https://nedap.com/"><img width="170" src="/images/logo-nedap.png"></a> <span class="sponsor-space"> </span> <a class="sponsor" href="https://www.foconis.de/"><img src="/images/sponsor_foconis_logo.png"></a> <span class="sponsor-space"> </span> <a class="sponsor" href="https://www.timerbee.de/"><img width="190" src="/images/logo-timerbee.png"></a> </div> </div> <section class="grid g3 mtx"> <div class="col-md-4"> <h3>Databases supported</h3> <p> <a href="/docs/database/h2">H2</a>, <a href="/docs/database/postgres">Postgres</a>, <a href="/docs/database/mysql">MySql</a>, <a href="/docs/database/nuodb">NuoDB</a>, <a href="/docs/database/postgres/postgis">PostGIS</a>, <a href="/docs/database/mariadb">MariaDB</a>, <a href="/docs/database/sqlserver">SQL Server</a>, <a href="/docs/database/oracle">Oracle</a>, <a href="/docs/database/hana">SAP Hana</a>, <a href="/docs/database/cockroach">CockroachDB</a>, <a href="/docs/database/clickhouse">Clickhouse</a>, <a href="/docs/database/sqlite">Sqlite</a>. </p> </div> <div class="col-md-4"> <h3>Multiple abstraction levels</h3> <p> Ebean provides multiple levels of query abstraction. </p> <ul> <li><a href="/docs/intro/queries/orm-query">ORM Queries, mixed with SQL</a></li> <li><a href="/docs/intro/queries/dto-query">DTO Queries</a></li> <li><a href="/docs/intro/queries/sql-query">SqlQuery and JDBC</a></li> </ul> <p> Work at the highest level of abstraction and drop down levels as needed. </p> </div> <div class="col-md-4"> <h3>Benefits of ORM</h3> <ul> <li>Automatically avoid N+1</li> <li>L2 caching to reduce database load</li> <li>Queries mixing database and L2 cache</li> <li>Automatically tune ORM queries</li> <li>Elasticsearch for search or L3 cache.</li> </ul> </div> <div class="col-md-4"> <h3>Docker test containers</h3> <p> <a href="/docs/testing">Docker test containers</a> for all the supported databases. </p> <p> Get 100% test coverage on all the features of the database we use. </p> </div> <div class="col-md-4"> <h3>Database migrations</h3> <p> Built in <a href="/docs/db-migrations">DB migration</a> generation and running. </p> <p> Support for "rebase" migrations as well as repeatable, init and 'normal' migrations. </p> </div> <div class="col-md-4"> <h3>Type safe queries</h3> <p> We can build queries using type safe <a href="/docs/query/query-beans">query beans</a>. <p> <p> IDE auto-complete when writing queries, compile time checking and it's FUN. </p> </div> <div class="col-md-4"> <h3>Automated query tuning</h3> <p> For ORM queries Ebean can profile the object graph being used and either <a href="/docs/query/background/autotune">automatically tune the query</a>. </p> </div> <div class="col-md-4"> <h3>Awesome SQL</h3> <p> Ebean produces SQL that you would hand craft yourself. </p> <p> Use great SQL, never generate SQL cartesian product, always honor relational limit/offset. </p> </div> <div class="col-md-4"> <h3>Performance isn't optional</h3> <p> <a href="/docs/query/fetchgroup">Optimise queries</a> to only fetch what we need (partial objects). </p> <p> Automatically avoid N+1 via a smart load context. </p> </div> </section> <section class="mtx" style="text-align: center;"> <h4><a href="/sponsors">silver sponsors</a></h4> <span class="avatar-gap"></span> <div class="avatar-circle"> <span class="initials">MH</span> </div> <span class="avatar-name">Maximilian Holtzberg</span> <span class="avatar-gap"></span> <div class="avatar-circle"> <span class="initials">SH</span> </div> <span class="avatar-name">Szabolcs Hubai</span> <span class="avatar-gap"></span> <div class="avatar-circle"> <span class="initials small">AMAH</span> </div> <span class="avatar-name">Al-Mothafar Al-Hasan</span> <span class="avatar-gap"></span> <div class="avatar-circle"> <span class="initials small">SL</span> </div> <span class="avatar-name">Sando Leinzinger</span> </section> <p class="mtx"> </p> <h2>About Ebean</h2> <section class="grid g2 summary"> <aside> <h3>JPA Mapping</h3> <p> Ebean uses JPA mapping annotations. </p> <p> Extra mappings ebean provides include:<br> <a href="/docs/mapping/extensions/dbjson">@DbJson</a>, <a href="/docs/mapping/extensions/dbarray">@DbArray</a>, <a href="/docs/mapping/extensions/dbpartition">@DbPartition</a>, <a href="/docs/mapping/extensions/history">@History</a>, <a href="/docs/mapping/extensions/when-modified">@WhenModified</a>, <a href="/docs/mapping/extensions/who-modified">@WhoModified</a>, <a href="/docs/mapping/extensions/soft-delete">@SoftDelete</a>, <a href="/docs/mapping/extensions/encrypted">@Encrypted</a> <a href="/docs/mapping/">more ...</a> </p> </aside> <div> <div class="syntax java"><div class="highlight"><pre><span></span><span class="nd">@Entity</span> <span class="nd">@Table</span><span class="o">(</span><span class="nx">name</span><span class="o">=</span><span class="s">"customer"</span><span class="o">)</span> <span class="kd">public</span> <span class="kd">class</span> <span class="nc">Customer</span> <span class="kd">extends</span> <span class="n">BaseModel</span> <span class="o">{</span> <span class="nd">@Column</span><span class="o">(</span><span class="nx">length</span><span class="o">=</span><span class="mi">100</span><span class="o">)</span> <span class="n">String</span> <span class="n">name</span><span class="o">;</span> <span class="nd">@ManyToOne</span><span class="o">(</span><span class="nx">cascade</span><span class="o">=</span><span class="nx">CascadeType</span><span class="o">.</span><span class="na">ALL</span><span class="o">)</span> <span class="n">Address</span> <span class="n">billingAddress</span><span class="o">;</span> <span class="nd">@OneToMany</span><span class="o">(</span><span class="nx">mappedBy</span><span class="o">=</span><span class="s">"customer"</span><span class="o">)</span> <span class="n">List</span><span class="o"><</span><span class="n">Contact</span><span class="o">></span> <span class="n">contacts</span><span class="o">;</span> <span class="o">...</span> </pre></div> </div> </div> <aside> <h3>Simple to use</h3> <p> Ebean provides a simple programming model that developers can understand and master quickly. </p> </aside> <div> <div class="syntax java"><div class="highlight"><pre><span></span><span class="c1">// insert ...</span> <span class="n">Customer</span> <span class="n">customer</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Customer</span><span class="o">(</span><span class="s">"Joe"</span><span class="o">);</span> <span class="n">customer</span><span class="o">.</span><span class="na">save</span><span class="o">();</span> <span class="o">...</span> <span class="c1">// find and update ...</span> <span class="n">Customer</span> <span class="n">customer</span> <span class="o">=</span> <span class="n">Customer</span><span class="o">.</span><span class="na field">find</span><span class="o">.</span><span class="na">byId</span><span class="o">(</span><span class="mi">42</span><span class="o">);</span> <span class="n">customer</span><span class="o">.</span><span class="na">setName</span><span class="o">(</span><span class="s">"Montana"</span><span class="o">);</span> <span class="n">customer</span><span class="o">.</span><span class="na">save</span><span class="o">();</span> </pre></div> </div> </div> <aside> <h3>Type safe queries</h3> <p> We can use <a href="/docs/query/query-beans">Query beans</a> to build queries in a type safe manner. </p> </aside> <div> <div class="syntax java"><div class="highlight"><pre><span></span><span class="n">List</span><span class="o"><</span><span class="n">Customer</span><span class="o">></span> <span class="n">customers</span> <span class="o">=</span> <span class="k">new</span> <span class="n">QCustomer</span><span class="o">()</span> <span class="o">.</span><span class="na field">name</span><span class="o">.</span><span class="na">istartsWith</span><span class="o">(</span><span class="s">"rob"</span><span class="o">)</span> <span class="o">.</span><span class="na field">billingAddress</span><span class="o">.</span><span class="na field">city</span><span class="o">.</span><span class="na">equalTo</span><span class="o">(</span><span class="s">"Auckland"</span><span class="o">)</span> <span class="o">.</span><span class="na">setMaxRows</span><span class="o">(</span><span class="mi">10</span><span class="o">)</span> <span class="o">.</span><span class="na">orderBy</span><span class="o">()</span> <span class="o">.</span><span class="na field">name</span><span class="o">.</span><span class="na">asc</span><span class="o">()</span> <span class="o">.</span><span class="na">findList</span><span class="o">();</span> </pre></div> </div> </div> </section> </article> </div> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <script src="/js/site3.js"></script> <script src="/js/search3.js"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-75181644-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-75181644-1'); </script> </body> </html>