我想选择Autor,并选择Concat the Mangas。
我尝试过使用GROUP_CONCAT()但不能在AutorRepository中工作。
#AutorRepository
@Query("Select a, GROUP_CONCAT(m.nome) FROM AutorEntity a, MangasEntity m ")
List<AutorEntity> buscarAutorEMangas();
#AutorController
@RequestMapping(value="/autor1", method= RequestMethod.GET)
public List<AutorEntity> ProcurarAutorEManga(){
return autorRepository.buscarAutorEMangas();
}
#Table Autor
@Entity
@Table(name = "Autor")
public class AutorEntity {
private Long id;
private String nome;
@JsonIgnore
@ManyToOne
@JoinTable(name="mangas_autor",
joinColumns=@JoinColumn(name="manga_id",referencedColumnName="id"),
inverseJoinColumns = @JoinColumn(name="autor_id",referencedColumnName="id"))
private List<MangasEntity> manga;
#Table Mangas
@Entity
@Table(name = "Mangas")
public class MangasEntity implements Serializable{
private Long id;
private String nome;
private Status status;
private Date dataLancado;
private AutorEntity autor;
private List<GenerosEntity> genero
@OneToMany(cascade= CascadeType.ALL,mappedBy="autor")
public List<MangasEntity> getManga() {
return manga;
}
在MySQL中查询,选择AUTOR和CONCAT漫画名称
选择a。*,GROUP_CONCAT(m.nome) 来自autor a 加入mangas_autor ma ON ma.autor_id = a.id. 加入漫画m ON ma.manga_id = m.id. GROUP BY a.nome
如何选择Autor并获得每个autor的Mangas?
请问任何想法?