package in.ac.amu.zhcet.data.model.base.user;

import in.ac.amu.zhcet.data.model.base.entity.BaseEntity;
import lombok.*;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@Entity
@DynamicUpdate
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(exclude = "password")
public class UserAuth extends BaseEntity {

    public static final PasswordEncoder PASSWORD_ENCODER = new BCryptPasswordEncoder();

    @Id
    private String userId;

    @NotNull
    private String password;
    @NotNull
    private String[] roles;

    @NotNull
    private String name;
    @NotNull
    private String type;

    public UserAuth(String userId, String password, String name, String type, String[] roles) {
        setUserId(userId);
        setPassword(password);
        setName(name);
        setType(type);
        setRoles(roles);
    }
}

@@ -378,16 +378,41 @@
 NotNull;
+%0Aimport java.util.Arrays;
 %0A%0A@Entit
@@ -768,18 +768,16 @@
 ring
-%5B%5D
  roles;%0A
 %0A   
@@ -772,17 +772,16 @@
  roles;%0A
-%0A
     @Not
@@ -1045,24 +1045,24 @@
 Type(type);%0A
-
         setR
@@ -1079,11 +1079,180 @@
 );%0A    %7D
+%0A%0A    public void setRoles(String%5B%5D roles) %7B%0A        this.roles = String.join(%22,%22, roles);%0A    %7D%0A%0A    public String%5B%5D getRoles() %7B%0A        return roles.split(%22,%22);%0A    %7D
 %0A%7D%0A

Use concatenated string for user roles