Im struggeling to understand Hibernate HQL, being only used to sql, i dont understand whats wrong with my HQL. Any help would be greatly appriciated:
@Entity
public class KursKode {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String kursKode;
private boolean used;
@ManyToOne
@JoinColumn (name = "kursId")
@LazyCollection(LazyCollectionOption.FALSE)
private Kurs kurs;
....
}
Im trying to fetch only “KursKode”‘s for a specific Kurs. And only “KursKodes” that have “used=false”. So i tried this in my DAO:
List<KursKode> kursKodeList = getHibernateTemplate().find("from KursKode k where k.kurs.kursId = ? and not k.used", kursId);
But this gives me the following error:
Data Access Failure
unexpected AST node: . near line 1, column 74 [from no.dahlsdata.model.Kurs.KursKode k where k.kurs.kursId = ? and not k.used]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: . near line 1, column 74 [from no.dahlsdata.model.Kurs.KursKode k where k.kurs.kursId = ? and not k.used]
Problem was only small. I forgot to put =false on the end. Here is what it should be: