Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HQL: Using Boolean in Named Queries

Tags:

Can you please help me? I have error in querying boolean value "r.isDefault = true".

In my HQL named query:

<named-query name="RptQuery.queryDefaultByCode">     <query>         SELECT r FROM RptQuery r WHERE r.code = ?1 AND r.isDefault = true     </query> </named-query> 

I get error: Caused by: org.hibernate.HibernateException: Errors in named queries: RptQuery.queryDefaultByCode

In my persistence.xml:

<property name="hibernate.query.substitutions" value="true='Y', false='N', yes='Y', no='N'"/> 

In my pojo:

private boolean isDefault;  @Column(name = "CPMN_IS_DEFLT", length = 1) @Type(type = "yes_no") public boolean isDefault() {     return this.isDefault; }  public void setDefault(boolean isDefault) {     this.isDefault = isDefault; } 

Thank you in advance!

Answer: Just found a minor error:

r.isDefault = true 

should be

r.default = true 

Thanks.

like image 999
Jemru Avatar asked Jan 05 '12 07:01

Jemru


1 Answers

try this : where r.isDefault is true

like image 99
giannisapi Avatar answered Oct 21 '22 16:10

giannisapi