I have a request in Hibernate that was working just fine in an older version of hibernate but after upgrading to a more recent one I have an error
org.hibernate.query.SemanticException: A query exception occurred [SELECT count(c) FROM Client c WHERE c.tmp_batch IS TRUE]
line 1:65 no viable alternative at input 'SELECTcount(c)FROMClientcWHEREc.tmp_batchISTRUE'
public Long getClientCount() {
return getEntityManager().createQuery("SELECT count(c) FROM Client c WHERE c.tmp_batch IS TRUE", Long.class)
.getResultList()
.get(0);
}
After testing a few things, I've got a solution for this problem that replace the IS TRUE
by = TRUE
and now it works fine again:
public Long getClientCount() {
return getEntityManager().createQuery("SELECT count(c) FROM Client c WHERE c.tmp_batch = TRUE", Long.class)
.getResultList()
.get(0);
}
But I'm unable to understand what's the difference between the two that make the first one to version fall in error, can someone explain the difference here ?
For reference, I'm adding the Client
class here :
@Entity
@Table(name = "CLIENTS")
@IdClass(ClientId.class)
public class Client {
@Id
@Column(name = "TMP_BATCH")
private boolean tmp_batch;
...
public boolean isTmp_batch() { return this.tmp_batch; }
public boolean setTmp_batch(boolean tmp_batch) { this.tmp_batch = tmp_batch; }
...
}