@@ -51,14 +51,14 @@ import io.quarkus.security.jpa.UserDefinition;
5151import io.quarkus.security.jpa.Username;
5252
5353@Entity
54- @Table(name = "test_user")
55- @UserDefinition <1 >
54+ @Table(name = "test_user") <1>
55+ @UserDefinition <2 >
5656public class User extends PanacheEntity {
57- @Username <2 >
57+ @Username <3 >
5858 public String username;
59- @Password <3 >
59+ @Password <4 >
6060 public String password;
61- @Roles <4 >
61+ @Roles <5 >
6262 public String role;
6363
6464 /**
@@ -67,7 +67,7 @@ public class User extends PanacheEntity {
6767 * @param password the unencrypted password (it is encrypted with bcrypt)
6868 * @param role the comma-separated roles
6969 */
70- public static void add(String username, String password, String role) { <5 >
70+ public static void add(String username, String password, String role) { <6 >
7171 User user = new User();
7272 user.username = username;
7373 user.password = BcryptUtil.bcryptHash(password);
@@ -80,12 +80,13 @@ public class User extends PanacheEntity {
8080
8181The `quarkus-security-jpa` extension initializes only if a single entity is annotated with `@UserDefinition`.
8282
83- <1> The `@UserDefinition` annotation must be present on a single entity, either a regular Hibernate ORM entity or a Hibernate ORM with Panache entity.
84- <2> Indicates the field used for the username.
85- <3> Indicates the field used for the password.
83+ <1> Table name. Do not define it as `user`, which is a restricted keyword in most databases.
84+ <2> The `@UserDefinition` annotation must be present on a single entity, either a regular Hibernate ORM entity or a Hibernate ORM with Panache entity.
85+ <3> Indicates the field used for the username.
86+ <4> Indicates the field used for the password.
8687By default, `quarkus-security-jpa` uses bcrypt-hashed passwords, or you can configure plain text or custom passwords instead.
87- <4 > This indicates the comma-separated list of roles added to the target principal representation attributes.
88- <5 > This method lets you add users while hashing passwords with the proper `bcrypt` hash.
88+ <5 > This indicates the comma-separated list of roles added to the target principal representation attributes.
89+ <6 > This method lets you add users while hashing passwords with the proper `bcrypt` hash.
8990
9091
9192== Jakarta Persistence entity as storage of roles
0 commit comments