I set unique constraint for username using @Column(unique=true)
what would be the best practice to check duplicate value before inserting the data to database?
- By catching the exception which will throw by the program when you try to insert data having same username.
- Check database if the provided username is already exists before trying to insert.