File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ <h2 id="identity">@Identity</h2>
231
231
232
232
< h2 id ="uuid "> UUID</ h2 >
233
233
< p >
234
- If the @Id type is < code > UUID</ code > then Ebean will automatically assign an appropriate Id generator
234
+ If the < em > @Id</ em > type is < code > UUID</ code > then Ebean will automatically assign an appropriate Id generator
235
235
to that property.
236
236
</ p >
237
237
< div class ="syntax java "> < div class ="highlight "> < pre > < span > </ span > < span class ="c1 "> // an appropriate UUID based Id generator</ span >
@@ -241,6 +241,21 @@ <h2 id="uuid">UUID</h2>
241
241
</ pre > </ div >
242
242
</ div >
243
243
244
+ < h2 id ="uuid-generatedValue "> UUID and @GeneratedValue</ h2 >
245
+ < p >
246
+ If we have a < code > UUID</ code > that is < b > NOT</ b > the < em > @Id</ em > we can add < code > @GeneratedValue</ code > and
247
+ then Ebean will assign a appropriate UUID generator to it.
248
+ </ p >
249
+ < div class ="syntax java "> < div class ="highlight "> < pre > < span > </ span > < span class ="cm "> /** The Id property using DB Identity or Sequence */</ span >
250
+ < span class ="nd "> @Id</ span > < span class ="nd "> @GeneratedValue</ span >
251
+ < span class ="kd "> private</ span > < span class ="kt "> long</ span > < span class ="n "> id</ span > < span class ="o "> ;</ span >
252
+
253
+ < span class ="cm "> /** Alternate unique UUID property */</ span >
254
+ < span class ="nd "> @GeneratedValue</ span > < span class ="nd "> @Column</ span > < span class ="o "> (</ span > < span class ="nx "> unique</ span > < span class ="o "> =</ span > < span class ="kc "> true</ span > < span class ="o "> )</ span >
255
+ < span class ="kd "> private</ span > < span class ="n "> UUID</ span > < span class ="n "> uid</ span > < span class ="o "> ;</ span >
256
+ </ pre > </ div >
257
+ </ div >
258
+
244
259
< h2 id ="string "> String</ h2 >
245
260
< p >
246
261
If the @Id type is < code > String</ code > then Ebean assumes that the id value is supplied by the
Original file line number Diff line number Diff line change @@ -151,6 +151,23 @@ <h1 id="breadcrumb">
151
151
</ form >
152
152
153
153
154
+ < h2 id ="generatedValue "> @GeneratedValue</ h2 >
155
+ < p >
156
+ If we have a < code > UUID</ code > that is not the < em > @Id</ em > we
157
+ can add < code > @GeneratedValue</ code > and
158
+ then Ebean will assign a appropriate UUID generator to it.
159
+ </ p >
160
+ < div class ="syntax java "> < div class ="highlight "> < pre > < span > </ span > < span class ="cm "> /** The Id property using DB Identity or Sequence */</ span >
161
+ < span class ="nd "> @Id</ span > < span class ="nd "> @GeneratedValue</ span >
162
+ < span class ="kd "> private</ span > < span class ="kt "> long</ span > < span class ="n "> id</ span > < span class ="o "> ;</ span >
163
+
164
+ < span class ="cm "> /** Alternate unique UUID property */</ span >
165
+ < span class ="nd "> @GeneratedValue</ span > < span class ="nd "> @Column</ span > < span class ="o "> (</ span > < span class ="nx "> unique</ span > < span class ="o "> =</ span > < span class ="kc "> true</ span > < span class ="o "> )</ span >
166
+ < span class ="kd "> private</ span > < span class ="n "> UUID</ span > < span class ="n "> uid</ span > < span class ="o "> ;</ span >
167
+ </ pre > </ div >
168
+ </ div >
169
+
170
+
154
171
< h2 > Native storage</ h2 >
155
172
< p >
156
173
UUID has native support in the following database platforms:
You can’t perform that action at this time.
0 commit comments