-1
Good morning, I am trying to delete my user class but am having the following error "Cannot delete or update a Parent Row: a Foreign key Constraint fails (pitangdb.phone, CONSTRAINT FKss9h0qo6opj3b1hvh9k3x3o9j FOREIGN KEY (idUser) REFERENCES user (userId))", would have some way to resolve this directly by JPA?
@Entity
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long userId;
    @Column(nullable = false)
    @Size(min = 2, max = 50)
    private String name;
    @Column(nullable = false)
    @Size(min = 2, max = 100)
    private String email;
    @Column(nullable = false)
    @Size(min = 6, max = 50)
    private String password;
    
    
    @OneToMany(mappedBy = "user", orphanRemoval = true)
    @Column(name = "phones", nullable = false)
    private List<Phone> phones;
@Entity
public class Phone {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long idPhone;
    
    
    @ManyToOne(cascade = CascadeType.DETACH)
    @JoinColumn(name = "idUser")
    private User user;
    
    @Column
    private String number;
    
    @Column
    private String typePhone;
						
I wanted to understand who signaled as a negative answer, which could have been done better in the answer, since I sought to contribute reproducing the code, did not generate error and posted the same here for demonstration.
– leandro.dev