I'm newbie with spring and I'm trying create an apiRest
@Repository
public interface IPersonajeDao extends JpaRepository<Personaje, Long> {
@Query( nativeQuery = true, value="SELECT imagen,nombre FROM personaje")
public List<Personaje> getAll();
I have this query in the repository, this query should get the fields image and name from the table "personaje"
When I running the aplication I get this error = "java.sql.SQLException: Column 'id' not found." Why it is?
service:
@Override
@Transactional
public List<Personaje> getAll() {
return this.personajeRepository.getAll();
}
Entity:
@Id
private long id;
private String imagen;
private String nombre;
private int edad;
private String historia;
public Personaje(long id, String imagen, String nombre, int edad, String historia) {
this.imagen = imagen;
this.nombre = nombre;
this.edad = edad;
this.historia = historia;
}
public Personaje() {
}
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@JoinTable(
name = "participa",
joinColumns = @JoinColumn(name = "FK_PERSONAJE", nullable = false),
inverseJoinColumns = @JoinColumn(name="FK_SERIE", nullable = false))
private List<Serie> series;
}