Skip to content

Commit a914278

Browse files
committed
Update @id and @Identity
1 parent 827eb44 commit a914278

File tree

3 files changed

+130
-59
lines changed

3 files changed

+130
-59
lines changed

docs/mapping/extensions/identity.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ <h3>cache value</h3>
243243
database should generate and cache ahead of time reducing the internal locking the database
244244
uses. Databases supporting this include Postgres, Oracle & NuoDB.
245245
</p>
246+
<h2 id="application">@Identity(type = APPLICATION)</h2>
247+
<p>
248+
We can use the ebean <code>@Identity</code> annotation with type set to <code>APPLICATION</code>
249+
to explicitly specify that the id value will be supplied by the application rather than
250+
generated by Database Identity or Sequence.
251+
</p>
252+
<pre type="java">
253+
@Id @Identity(type=APPLICATION)
254+
long id;
255+
</pre>
246256

247257

248258

docs/mapping/jpa/id.html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,38 @@ <h2 id="generated-value">@GeneratedValue</h2>
199199
</pre></div>
200200
</div>
201201

202+
203+
<h2 id="idGeneratorAutomatic">idGeneratorAutomatic</h2>
204+
<p>
205+
We can disable the automatic generation of Id values by configuring
206+
<code>idGeneratorAutomatic</code> to be <code>false</code>.
207+
</p>
208+
<p>
209+
configure via properties:
210+
</p>
211+
<div class="syntax properties"><div class="highlight"><pre><span></span><span class="na">ebean.idGeneratorAutomatic</span><span class="o">=</span><span class="s">false</span>
212+
</pre></div>
213+
</div>
214+
<p>
215+
configure via code:
216+
</p>
217+
<div class="syntax java"><div class="highlight"><pre><span></span><span class="n">DatabaseConfig</span><span class="o">.</span><span class="na">setIdGeneratorAutomatic</span><span class="o">(</span><span class="kc">false</span><span class="o">)</span>
218+
</pre></div>
219+
</div>
220+
<p>
221+
With idGeneratorAutomatic disabled then we need to explicitly add the
222+
<code>@GeneratedValue</code> to every <code>@Id</code> property that
223+
we want to have generated values via Database Identity or Sequence.
224+
</p>
225+
<p>
226+
Alternatively we can use <a href="/docs/mapping/extensions/identity#application">@Identity</a>
227+
with <code>type=APPLICATION</code> to explicitly specify that the id value
228+
will be supplied by the application.
229+
</p>
230+
202231
<h2 id="identity">@Identity</h2>
203232
<p>
204-
Ebean additionally has an <a href="/docs/mapping/identity">@Identity</a> annotation
233+
Ebean additionally has an <a href="/docs/mapping/extensions/identity">@Identity</a> annotation
205234
when we want to use to specify the <code>starts value</code>, <code>cache value</code> and
206235
<code>generated by default|always</code> options for database identity or sequence.
207236
</p>

search.json

Lines changed: 90 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,14 @@
487487
"keywords":"",
488488
"url":"/docs/trouble-shooting#registered"
489489
}
490+
,{
491+
"title":"Trouble shooting - Transient Initialisation",
492+
"caption":"",
493+
"category":"Introduction",
494+
"priority":"2",
495+
"keywords":"",
496+
"url":"/docs/trouble-shooting#transient-initialisation"
497+
}
490498
,{
491499
"title":"Trouble shooting - java.lang.IllegalStateException: Bean class _ is not enhanced?",
492500
"caption":"",
@@ -631,6 +639,14 @@
631639
"keywords":"",
632640
"url":"/docs/db-migrations#db-migrations"
633641
}
642+
,{
643+
"title":"Dependencies",
644+
"caption":"",
645+
"category":"DB migrations",
646+
"priority":"3",
647+
"keywords":"",
648+
"url":"/docs/db-migrations#dependencies"
649+
}
634650
,{
635651
"title":"Details",
636652
"caption":"",
@@ -1159,22 +1175,6 @@
11591175
"keywords":"",
11601176
"url":"/docs/database/postgres#ebean-postgres"
11611177
}
1162-
,{
1163-
"title":"Postgres / Array type",
1164-
"caption":"",
1165-
"category":"Database platforms",
1166-
"priority":"3",
1167-
"keywords":"",
1168-
"url":"/docs/database/postgres/arraytype"
1169-
}
1170-
,{
1171-
"title":"Postgres / PostGIS",
1172-
"caption":"",
1173-
"category":"Database platforms",
1174-
"priority":"3",
1175-
"keywords":"",
1176-
"url":"/docs/database/postgres/postgis"
1177-
}
11781178
,{
11791179
"title":"Redis - L2 cache",
11801180
"caption":"",
@@ -1407,38 +1407,6 @@
14071407
"keywords":"",
14081408
"url":"/docs/features"
14091409
}
1410-
,{
1411-
"title":"CLI tool - ebeaninit",
1412-
"caption":"",
1413-
"category":"Getting started",
1414-
"priority":"3",
1415-
"keywords":"",
1416-
"url":"/docs/getting-started/cli-tool"
1417-
}
1418-
,{
1419-
"title":"CLI tool - ebeaninit - CLI Tool - ebeaninit",
1420-
"caption":"",
1421-
"category":"Getting started",
1422-
"priority":"3",
1423-
"keywords":"",
1424-
"url":"/docs/getting-started/cli-tool"
1425-
}
1426-
,{
1427-
"title":"CLI tool - ebeaninit / Manual install",
1428-
"caption":"",
1429-
"category":"Getting started",
1430-
"priority":"3",
1431-
"keywords":"",
1432-
"url":"/docs/getting-started/cli-tool-manualinstall"
1433-
}
1434-
,{
1435-
"title":"CLI tool - ebeaninit / Manual install - Manual installation (Linux)",
1436-
"caption":"",
1437-
"category":"Getting started",
1438-
"priority":"3",
1439-
"keywords":"",
1440-
"url":"/docs/getting-started/cli-tool-manualinstall#manual"
1441-
}
14421410
,{
14431411
"title":"Eclipse IDE",
14441412
"caption":"",
@@ -1536,44 +1504,44 @@
15361504
"url":"/docs/getting-started/maven"
15371505
}
15381506
,{
1539-
"title":"Maven - Dependencies",
1507+
"title":"Maven - Example pom for Postgres",
15401508
"caption":"",
15411509
"category":"Getting started",
15421510
"priority":"3",
15431511
"keywords":"",
1544-
"url":"/docs/getting-started/maven#dependencies"
1512+
"url":"/docs/getting-started/maven"
15451513
}
15461514
,{
1547-
"title":"Maven - Examples",
1515+
"title":"Maven - JDBC Driver(s)",
15481516
"caption":"",
15491517
"category":"Getting started",
15501518
"priority":"3",
15511519
"keywords":"",
1552-
"url":"/docs/getting-started/maven"
1520+
"url":"/docs/getting-started/maven#jdbc-dep"
15531521
}
15541522
,{
1555-
"title":"Maven - Kotlin KAPT",
1523+
"title":"Maven - Main dependency",
15561524
"caption":"",
15571525
"category":"Getting started",
15581526
"priority":"3",
15591527
"keywords":"",
1560-
"url":"/docs/getting-started/maven#kotlin-kapt"
1528+
"url":"/docs/getting-started/maven#dependencies"
15611529
}
15621530
,{
1563-
"title":"Maven - build / plugins",
1531+
"title":"Maven - Test dependency - ebean-test",
15641532
"caption":"",
15651533
"category":"Getting started",
15661534
"priority":"3",
15671535
"keywords":"",
1568-
"url":"/docs/getting-started/maven"
1536+
"url":"/docs/getting-started/maven#testDependencies"
15691537
}
15701538
,{
1571-
"title":"Maven / Plugin",
1539+
"title":"Maven - build / plugins",
15721540
"caption":"",
15731541
"category":"Getting started",
15741542
"priority":"3",
15751543
"keywords":"",
1576-
"url":"/docs/getting-started/maven-plugin"
1544+
"url":"/docs/getting-started/maven"
15771545
}
15781546
,{
15791547
"title":"Prerequisite - Java 11",
@@ -1591,6 +1559,14 @@
15911559
"keywords":"",
15921560
"url":"/docs/getting-started/ebean-test"
15931561
}
1562+
,{
1563+
"title":"jakarata and javax persisence",
1564+
"caption":"",
1565+
"category":"Getting started",
1566+
"priority":"3",
1567+
"keywords":"",
1568+
"url":"/docs/getting-started#Jakarata"
1569+
}
15941570
,{
15951571
"title":"@OneToMany",
15961572
"caption":"",
@@ -1927,6 +1903,14 @@
19271903
"keywords":"",
19281904
"url":"/docs/mapping/extensions/dbenumvalue#storage"
19291905
}
1906+
,{
1907+
"title":"Extension / @DbForeignKey",
1908+
"caption":"",
1909+
"category":"Mapping",
1910+
"priority":"3",
1911+
"keywords":"",
1912+
"url":"/docs/mapping/extensions/dbforeignkey"
1913+
}
19301914
,{
19311915
"title":"Extension / @DbJson",
19321916
"caption":"",
@@ -2039,6 +2023,14 @@
20392023
"keywords":"",
20402024
"url":"/docs/mapping/extensions/identity"
20412025
}
2026+
,{
2027+
"title":"Extension / @Identity - @Identity(type = APPLICATION)",
2028+
"caption":"",
2029+
"category":"Mapping",
2030+
"priority":"3",
2031+
"keywords":"",
2032+
"url":"/docs/mapping/extensions/identity#application"
2033+
}
20422034
,{
20432035
"title":"Extension / @Index",
20442036
"caption":"",
@@ -2103,6 +2095,22 @@
21032095
"keywords":"",
21042096
"url":"/docs/mapping/extensions/view"
21052097
}
2098+
,{
2099+
"title":"Extension / @View - Dependent Tables",
2100+
"caption":"",
2101+
"category":"Mapping",
2102+
"priority":"3",
2103+
"keywords":"",
2104+
"url":"/docs/mapping/extensions/view"
2105+
}
2106+
,{
2107+
"title":"Extension / @View - Extra DDL to define the view",
2108+
"caption":"",
2109+
"category":"Mapping",
2110+
"priority":"3",
2111+
"keywords":"",
2112+
"url":"/docs/mapping/extensions/view"
2113+
}
21062114
,{
21072115
"title":"Extension / @View - View",
21082116
"caption":"",
@@ -2247,6 +2255,22 @@
22472255
"keywords":"",
22482256
"url":"/docs/mapping/jpa/id#uuid"
22492257
}
2258+
,{
2259+
"title":"JPA / @Id - UUID and @GeneratedValue",
2260+
"caption":"",
2261+
"category":"Mapping",
2262+
"priority":"3",
2263+
"keywords":"",
2264+
"url":"/docs/mapping/jpa/id#uuid-generatedValue"
2265+
}
2266+
,{
2267+
"title":"JPA / @Id - idGeneratorAutomatic",
2268+
"caption":"",
2269+
"category":"Mapping",
2270+
"priority":"3",
2271+
"keywords":"",
2272+
"url":"/docs/mapping/jpa/id#idGeneratorAutomatic"
2273+
}
22502274
,{
22512275
"title":"JPA / @Lob",
22522276
"caption":"",
@@ -2567,6 +2591,14 @@
25672591
"keywords":"",
25682592
"url":"/docs/mapping/type/uuid"
25692593
}
2594+
,{
2595+
"title":"Types / UUID - @GeneratedValue",
2596+
"caption":"",
2597+
"category":"Mapping",
2598+
"priority":"3",
2599+
"keywords":"",
2600+
"url":"/docs/mapping/type/uuid#generatedValue"
2601+
}
25702602
,{
25712603
"title":"Types / UUID - Binary storage",
25722604
"caption":"",

0 commit comments

Comments
 (0)