Reputation: 21
I have 3 entities : project
, userProject
and standardProject
, both userProject
and standardProject
are a @ManyToOne
relationship with entity project
.
I want to display these entities in my Project view, to do so I implemented for both entities the following in my Project.java
:
@OneToMany(mappedBy = "projet", fetch = FetchType.EAGER)
private Set<UtilisateurProjet> utilisateurs = new HashSet<>();
@OneToMany(mappedBy = "projet")
private Set<StandardProjet> standardProjets = new HashSet<>();
And added the @JoinColumn
in both entities .java files :
@ManyToOne
@JoinColumn(name = "projet_id")
@JsonIgnoreProperties(value = "utilisateurs", allowSetters = true)
private Projet projet;
I display them in my React file. Important point, these relationships can be NULL, sometimes a Project do not have any user or standard related so the following column is empty in my view. However, this is working correctly for userProject
but not for standardProject
which throw me :
TypeError: Cannot read property 'map' of null
When I try to display them.
Any guess ?
Upvotes: 1
Views: 450