@GeneratedValue: Difference between revisions
Jump to navigation
Jump to search
(→Cases) |
|||
Line 14: | Line 14: | ||
=Cases= | =Cases= | ||
For a PostgreSQL table in which the primary key | For a PostgreSQL table in which the primary key was declared as follows: | ||
<syntaxhighlight lang='sql'> | <syntaxhighlight lang='sql'> | ||
id BIGINT UNIQUE GENERATED ALWAYS AS IDENTITY, | id BIGINT UNIQUE GENERATED ALWAYS AS IDENTITY, | ||
</syntaxhighlight> | </syntaxhighlight> | ||
the corresponding annotation combination: | the corresponding annotation combination: | ||
<syntaxhighlight lang='java'> | <syntaxhighlight lang='java'> |
Revision as of 04:31, 19 October 2018
Internal
Overview
@GeneratedValue(strategy = GenerationType.AUTO)
Used together with @Id when relying on the database to automatically generate the ID value, define "strategy = AUTO".
Cases
For a PostgreSQL table in which the primary key was declared as follows:
id BIGINT UNIQUE GENERATED ALWAYS AS IDENTITY,
the corresponding annotation combination:
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;