Select * from Table and No Select * from EntityName - JPA JAVA

2

My query was built like this, but when it asks:

@Query(value = "SELECT CT.id FROM CursoTurno AS CT 
                LEFT JOIN Curso AS C ON C.id = CT.curso_id 
                INNER JOIN Turno AS T ON T.id = CT.turno_id 
                WHERE C.id = :curso AND T.id = :turno",
                nativeQuery = true)

public CursoTurno findByCursoeTurno(@Param("curso") long curso, @Param("turno") long turno);

It results in this error

  

Caused by: org.postgresql.util.PSQLException: ERROR: relation   "cursoturno" does not exist

Course Entity

@Entity
@JsonIgnoreProperties({ "cursoTurnos", "unidade" })
@Table(name = "curso")
public class Curso implements Serializable {

    @NotNull
    @Valid
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "curso", orphanRemoval=true)
    private List<CursoTurno> cursoTurnos;

Turn Entity

@Entity
@Table(name = "turno")
@JsonIgnoreProperties({ "horarios","cursoTurnos" })
public class Turno implements Serializable {

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "turno")
    private List<CursoTurno> cursoTurnos;

Daylight Entity

@Entity
@Table(name = "curso_turno")
public class CursoTurno implements Serializable {
  @NotNull
  @ManyToOne
  @JoinColumn(name = "curso_id", referencedColumnName = "id")
  private Curso curso;

  @NotNull
  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn(name = "turno_id", referencedColumnName = "id")
  private Turno turno;

It is taking the name of the entity and not the name of the table. I researched how to fix it and found nothing compelling.

    
asked by anonymous 05.05.2017 / 13:36

0 answers