package com.example.spring.user.entity; import java.util.ArrayList; import java.util.Collection; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; /* @Table - Used to set the database table name explicitely. */ @Entity @Table(name="user_account") public class User implements UserDetails { /* GenerationType.IDENTITY - Auto generate value based on database's native auto increment feature */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(unique = true) private String username; private String password; /* Roles and permissions can be represented by GrantedAuthority instances. */ @Override public Collection getAuthorities() { return new ArrayList<>(); } @Override public String getPassword() { return password; } @Override public String getUsername() { return username; } }