File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ <h2 id="identity">@Identity</h2>
231231
232232< h2 id ="uuid "> UUID</ h2 >
233233< 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
235235 to that property.
236236</ p >
237237< 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>
241241</ pre > </ div >
242242</ div >
243243
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+
244259< h2 id ="string "> String</ h2 >
245260< p >
246261 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">
151151</ form >
152152
153153
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+
154171< h2 > Native storage</ h2 >
155172< p >
156173 UUID has native support in the following database platforms:
You can’t perform that action at this time.
0 commit comments