How to pass boolean parameter to new HQL constructor

The situation . I have a SubjectRow object that wraps a Subject (a Subject is a persistent object). I need to create a new wrapper object directly in HQL.

public class SubjectRow{
    Subject subject;
    String myString;
    boolean myBoolean;

    public SubjectRow(SubjectSch subject, String myString) {
        this.subject = subject;
        this.myString = myString;
    }

    public SubjectRow(SubjectSch subject, boolean myBoolean) {
        this.subject = subject;
        this.myBoolean = myBoolean;
    }


}

HQL for a constructor with a string (and it works as it should):

SELECT new package.SubjectRow(s, 'myString') FROM Subject s

Problem . The problem is that sometimes I need to call another constructor of this shell, which takes a boolean value instead of a string. I tried the same approach

SELECT new package.SubjectRow(s, true) FROM Subject s

But Hibernate complains that it cannot find the appropriate constructor in the SubjectRow class. Of course, I could pass the string, and then just do the appropriate casting - but it's too ugly.

: HQL / , ( Boolean)?

"" . , , . SubjectRow SubjectRowFalse SubjectRowTrue, . HQL

SELECT .SubjectRowTrue(s) FROM Subject s

SELECT .SubjectRowFalse(s) FROM Subject s

, ,

+3
1

100%, , Boolean- .

0

All Articles