I want to create an API with users where I can make referals to other user and store the users that refearal me.
@Entity
@Table(name="requirement")
@Data
@NoArgsConstructor
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "name")
private String name;
private User parentUser;
}
CREATE TABLE user(
id serial PRIMARY KEY,
name VARCHAR,
user_id INT,
what is the best way to handle this case
I want to create an API with users where I can make referals to other user and store the users that refearal me.