I have an entity class with a composite key,
@Entity
@Table(name = "PrimeHostDirectAccessHosts")
public class PrimeHostDirectAccessHost extends AbstractEntity<PrimeHostDirectAccessHostKey> {
private String carrierCodeThreeLetter;
public PrimeHostDirectAccessHost() {
}
public PrimeHostDirectAccessHost(String primeHostCode, String carrierCode, String carrierCodeThreeLetter) {
super.setId(new PrimeHostDirectAccessHostKey(primeHostCode, carrierCode));
this.carrierCodeThreeLetter = carrierCodeThreeLetter;
}
@EmbeddedId
@Override
public PrimeHostDirectAccessHostKey getId() {
return super.getId();
}
@Embeddable
public class PrimeHostDirectAccessHostKey implements Identity {
@Column(name = "primeHostCode")
private String primeHostCode;
@Column
private String carrierCode;
public PrimeHostDirectAccessHostKey() {
}
I am trying to run a simple JPQL query via my code,
private long getRowCount() {
return (Long) entityManager.createquery(String.format(select count(*) from PrimeHostDirectAccessHost where primeHostCode ='1F')).getResultList();
}
but i get the following error, java.lang.IllegalArgumentException: org.hibernate.query.SemanticException: Could not interpret path expression ‘primeHostCode’.
The DB is HSQL and I am using spring boot 3 with hibernate 6