Pregunta

I'm new to using JPQL/JPA and I somehow can't get this working:

public List<Bil> hentBiler(int kontor) {
List<Bil> biler = new ArrayList<Bil>(); 
TypedQuery<Bil> query = em.createQuery("SELECT o FROM Bil o WHERE o.kontornr = ?1", Bil.class);
query.setParameter(1, kontor);
}

The kontornr column in the database is an integer.

The error i recieve is this:

Exception Description: Problem compiling [SELECT o FROM Bil o WHERE o.kontornr = ?1]. 
[26, 36] The state field path 'o.kontornr' cannot be resolved to a valid type.


@Entity
public class Bil {
@Id
private String regNr;
private String merke;           
private String modell;          
private String farge;           
private char gruppe;            
private boolean ledig;          
private int kontorNr;
¿Fue útil?

Solución

The field is declared as

private int kontorNr;

The query is

SELECT o FROM Bil o WHERE o.kontornr = ?1

Java is case sensitive. kontronr != kontorNr.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top