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.

2
  • Thanks and it works, please post your solution as answer and accept your own answer. It will help others Commented Dec 16, 2018 at 14:45
  • 1
    Why it is r.default and not r.isDefault? Commented Oct 7, 2019 at 10:10

1 Answer 1

48

try this : where r.isDefault is true

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.