What I want to do is get data user and copy to a new user (create a new user). This is what I'm doing:

```
@Entity
@Table(name = "role")
public class Role {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "role_id")
    private int roleId;

    @Column(name = "role")
    private String role;

    public Role() {
    }
}

@Entity
@Table(name = "usuario")
public class Users {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "user_id")
    private int id;

    @Column(name = "email")
    private String email;

    @Column(name = "password", nullable=false, length=60)
    private String password;

    @Column(name = "name", unique=true, nullable=false, length=6)
    private String name;

    @Column(name = "last_name")
    private String lastName;

    @Column(name = "active", nullable=false)
    private int active;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
    private Set<Role> roles;

    public Users() {
    }

}

```

I get data from one existing user:

```
Optional<Users> user = usersRepository.findByName(name);

//create a new User to persist
Users newUser = new Users();
newUser.setName("new name");
newUser.setActive(1);
newUser.setEmail(user.get().getEmail());
newUser.setLastName(user.get().getLastName());
newUser.setPassword(user.get().getPassword());
Set<Role> roles = user.get().getRoles();

newUser.setRoles(roles);
usersRepository.save(newUser);  

```

I get this message:

**Found shared references to a collection: model.authentication.Users.roles; 
nested exception is org.hibernate.HibernateException: Found shared references to a collection: model.authentication.Users.roles**

**UPDATE 1 (SOLVED)**

```
        Optional<Users> user = usersRepository.findByName(codalojamiento);
        Users newUser = new Users();
        newUser.setName("new name");
        newUser.setActive(1);
        newUser.setEmail(user.get().getEmail());
        newUser.setLastName(user.get().getLastName());
        newUser.setPassword(user.get().getPassword());
        Set<Role> newRoles = new HashSet();
        Set<Role> roles = user.get().getRoles();
        for (Role r : roles) {
            newRoles.add(r);
        }
        newUser.setRoles(newRoles);
        usersRepository.save(newUser);

```

Any suggestion?
Thanks