0

I'm trying to update my user entity and I have an error that comes to mind: ERROR: A NULL value violates the NOT NULL constraint of the "id" column Detail: The failed row contains (null, 1, 1)

The problem surely stems from my relationship between user and profile which is n-n

public class Utilisateur implements Serializable {
private static final long serialVersionUID = 1L;

@Id
private Integer id;

private Integer fixe;

private Boolean deleted;

private Boolean actif;

private String email;

private Integer mobile;

private String motDePasse;

private String nom;

private String prenom;

@ManyToMany
private List<Profil> profils = new ArrayList<Profil>();

public Utilisateur() {
}
}

public class Profil implements Serializable {
private static final long serialVersionUID = 1L;

@Id
private Integer id;

private String codeProfil;

private String libelleProfil;

@JsonManagedReference
@ManyToMany
private List<MenuAction> menuActions = new ArrayList<MenuAction>();

public Profil() {
}
}
The Coder
  • 3,447
  • 7
  • 46
  • 81
dna
  • 486
  • 1
  • 9
  • 18

1 Answers1

0

How you generate value for your id? Seems you need some way to generate value for you ID. For example, use @GeneratedValue, like:

@GeneratedValue(strategy = IDENTITY)
marknote
  • 1,058
  • 8
  • 10
  • My problem is that I need a relationship entity between the two tables. See my other post : https://stackoverflow.com/questions/53882726/return-information-relation-many-to-many – dna Dec 21 '18 at 13:28