I have Film and Genre entities. Both of them have associations that refer to each other's classes:
@Data
@Entity
public class Film {
@Id
@Column(name = "film_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long filmId;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "film_genres",
joinColumns = @JoinColumn(name = "film_id", referencedColumnName = "film_id"),
inverseJoinColumns = @JoinColumn(name = "genre_id", referencedColumnName = "genre_id"))
private List<Genre> genres = new ArrayList<>();
}
@Data
@Entity
public class Genre {
@Id
@Column(name = "genre_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long genreId;
@ManyToMany(mappedBy = "genres", fetch = FetchType.EAGER)
private List<Film> films = new ArrayList<>();
}
And I have JpaRepositories with them.
The problem is that I get both films and genres ArrayLists as a link instead of array.
Here's how it looks:
{
"genreId" : 1,
"name" : "Comedy",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/genres/1"
},
"genre" : {
"href" : "http://localhost:8080/api/genres/1"
},
"films" : {
"href" : "http://localhost:8080/api/genres/1/films"
}
}
}
Can anybody help me out?