HQL: Using Boolean in Named Queries
Asked Answered
R

1

23

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.

Roseleeroselia answered 5/1, 2012 at 7:54 Comment(2)
Thanks and it works, please post your solution as answer and accept your own answer. It will help othersEliseoelish
Why it is r.default and not r.isDefault?Plunkett
F
48

try this : where r.isDefault is true

Fenny answered 26/4, 2012 at 14:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.