CINXE.COM

Mapping | Ebean

<!doctype html> <html lang="en"> <head> <title>Mapping | Ebean</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"> </head> <body> <div id="main"> <div id="banner"> <header> <nav id="top"> <h1 id="breadcrumb"> <a class="nav-logo" href="/"><img src="/images/logo-200.png" height="35"></a>&nbsp;&nbsp;<a href="/docs">Documentation</a><span class="sep">&nbsp;/&nbsp;</span><a href="/docs/mapping/">Mapping</a><span class="sep">&nbsp;/&nbsp;</span><a href="/docs/mapping/extension">Extension</a><span class="sep">&nbsp;/&nbsp;</span><span class="last">@WhenModified</span> </h1> <ul> <li><a onclick="toggleTheme();" title="switch dark light theme"><i class="fas fa-adjust"></i></a></li> </ul> </nav> </header> </div> <div class="grid grid-docs"> <aside> <nav class="side"> <ul> <li class="nav0 "> <a href="/docs/getting-started">Getting started</a> </li> <li class="nav0 "> <a href="/docs/intro">Introduction</a> </li> <li class="nav0 active"> <a class="active" href="/docs">Documentation</a> <ul> <li class="nav1 "> <a href="/docs/best-practice">Best practice</a> </li> <li class="nav1 "> <a href="/docs/query">Query</a> </li> <li class="nav1 "> <a href="/docs/persist">Persist</a> </li> <li class="nav1 "> <a href="/docs/transactions">Transactions</a> </li> <li class="nav1 active"> <a class="active" href="/docs/mapping">Mapping</a> <ul class="nav"> <li class="nav1 "> <a href="/docs/mapping/type">Types</a> </li> <li class="nav1 "> <a href="/docs/mapping/jpa">JPA</a> </li> <li class="nav1 active"> <a class="active" href="/docs/mapping/extensions">Extensions</a> <ul class="nav"> <li > <a href="/docs/mapping/extensions/identity">@Identity</a> </li> <li > <a href="/docs/mapping/extensions/dbindex">@Index</a> </li> <li > <a href="/docs/mapping/extensions/dbenumvalue">@DbEnumValue</a> </li> <li > <a href="/docs/mapping/extensions/dbjson">@DbJson</a> </li> <li > <a href="/docs/mapping/extensions/dbarray">@DbArray</a> </li> <li > <a href="/docs/mapping/extensions/dbmap">@DbMap</a> </li> <li > <a href="/docs/mapping/extensions/dbforeignkey">@DbForeignKey</a> </li> <li > <a href="/docs/mapping/extensions/dbcomment">@DbComment</a> </li> <li > <a href="/docs/mapping/extensions/dbpartition">@DbPartition</a> </li> <li > <a href="/docs/mapping/extensions/when-created">@WhenCreated</a> </li> <li class="active"> <a class="active" href="/docs/mapping/extensions/when-modified">@WhenModified</a> </li> <li > <a href="/docs/mapping/extensions/who-created">@WhoCreated</a> </li> <li > <a href="/docs/mapping/extensions/who-modified">@WhoModified</a> </li> <li > <a href="/docs/mapping/extensions/soft-delete">@SoftDelete</a> </li> <li > <a href="/docs/mapping/extensions/encrypted">@Encrypted</a> </li> <li > <a href="/docs/mapping/extensions/formula">@Formula</a> </li> <li > <a href="/docs/mapping/extensions/view">@View</a> </li> <li > <a href="/docs/mapping/extensions/history">@History</a> </li> <li > <a href="/docs/mapping/extensions/change-log">@ChangeLog</a> </li> <li > <a href="/docs/mapping/extensions/read-audit">@ReadAudit</a> </li> </ul> </li> </ul> </li> <li class="nav1 "> <a href="/docs/ddl-generation">DDL & Migrations</a> </li> <li class="nav1 "> <a href="/docs/logging">Logging</a> </li> <li class="nav1 "> <a href="/docs/testing">Testing</a> </li> <li class="nav1 "> <a href="/docs/read-replicas">Read Replicas</a> </li> <li class="nav1 "> <a href="/docs/database">Database platforms</a> </li> <li class="nav1 "> <a href="/docs/multi-database">Multiple databases</a> </li> <li class="nav1 "> <a href="/docs/kotlin">Kotlin</a> </li> <li><a href="/docs/tuning">Tuning</a></li> <li class="nav1 "> <a href="/docs/features">Features</a> </li> </ul> </li> <li class="nav0 "> <a href="/support">Getting help</a> </li> <li class="nav0 "> <a target="_blank" href="/apidoc/13">API Javadoc</a> </li> <li class="nav0 "> <a href="/videos">Videos</a> </li> <li class="nav0 "> <a href="/docs/upgrading">Upgrading</a> </li> <li class="nav0 "> <a href="/releases">Releases</a> </li> </ul> </nav> </aside> <article> <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> <h2>@WhenModified</h2> <p> A date time property managed by Ebean that is set on both <code>insert</code> and <code>update</code>. </p> <p> Typically we use both <code>@WhenCreated</code> and <code>@WhenModified</code> on a mapped superclass. </p> <p>&nbsp;</p> <h4>Example</h4> <div class="syntax java"><div class="highlight"><pre><span></span><span class="nd">@WhenCreated</span> <span class="kd">private</span> <span class="n">Instant</span> <span class="n">whenCreated</span><span class="o">;</span> <span class="nd">@WhenModified</span> <span class="kd">private</span> <span class="n">Instant</span> <span class="n">whenModified</span><span class="o">;</span> <span class="o">}</span> </pre></div> </div> <p>&nbsp;</p> <h4>Example on mapped superclass</h4> <div class="syntax java"><div class="highlight"><pre><span></span><span class="nd">@MappedSuperclass</span> <span class="kd">public</span> <span class="kd">abstract</span> <span class="kd">class</span> <span class="nc">BaseDomain</span> <span class="o">{</span> <span class="nd">@Id</span> <span class="kd">protected</span> <span class="n">UUID</span> <span class="n">id</span><span class="o">;</span> <span class="nd">@Version</span> <span class="kd">private</span> <span class="kt">long</span> <span class="n">version</span><span class="o">;</span> <span class="nd">@WhenCreated</span> <span class="kd">private</span> <span class="n">Instant</span> <span class="n">whenCreated</span><span class="o">;</span> <span class="nd">@WhenModified</span> <span class="kd">private</span> <span class="n">Instant</span> <span class="n">whenModified</span><span class="o">;</span> <span class="kd">public</span> <span class="n">UUID</span> <span class="nf">getId</span><span class="o">()</span> <span class="o">{</span> <span class="k">return</span> <span class="n">id</span><span class="o">;</span> <span class="o">}</span> <span class="kd">public</span> <span class="kt">long</span> <span class="nf">getVersion</span><span class="o">()</span> <span class="o">{</span> <span class="k">return</span> <span class="n">version</span><span class="o">;</span> <span class="o">}</span> <span class="kd">public</span> <span class="n">Instant</span> <span class="nf">getWhenCreated</span><span class="o">()</span> <span class="o">{</span> <span class="k">return</span> <span class="n">whenCreated</span><span class="o">;</span> <span class="o">}</span> <span class="kd">public</span> <span class="n">Instant</span> <span class="nf">getWhenModified</span><span class="o">()</span> <span class="o">{</span> <span class="k">return</span> <span class="n">whenModified</span><span class="o">;</span> <span class="o">}</span> <span class="o">}</span> </pre></div> </div> </article> </div> </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>

Pages: 1 2 3 4 5 6 7 8 9 10