1 Reply Latest reply on Aug 14, 2009 7:02 PM by santana2008

    Using a constructor expression in a SELECT clause

    santana2008
      Hi,

      I am try to use a constructor expression in a SELECT clause.

      this is the example :

      query :
      select new mypackage.DTOCourse(t, (select c from Course as c where t in c.teachers)) from Teacher as t";

      class :
      class DTOCourse {
              Teacher teacher;
              List<Course> courses;
             
              public DTOCourse(Teacher teacher, List<Course> courses) {
                      this.teacher = teacher;
                      this.courses = courses;
              }
      }

      where we have many to many association between teacher entity and course entity.

      the execution fails, sql exception : "expression absente"

      how can i construct my DTOCourse  using the teacher and the teachers courses as parameters ?

      10x in advance.
        • 1. Re: Using a constructor expression in a SELECT clause
          santana2008
          <blockquote>
          _Mohammed Ali El Karama wrote on Aug 14, 2009 18:46:_<br/>

          Hi,

          I am trying to use a constructor expression in a SELECT clause.

          this is the example :

          query :
          select new mypackage.DTOCourse(t, (select c from Course as c where t in c.teachers)) from Teacher as t";

          class :
          class DTOCourse {
                  Teacher teacher;
                  List<Course> courses;
                 
                  public DTOCourse(Teacher teacher, List<Course> courses) {
                          this.teacher = teacher;
                          this.courses = courses;
                  }
          }

          where we have many to many association between teacher entity and course entity.

          the execution fails, sql exception : "expression absente"

          how can i construct my DTOCourse  using the teacher and the teachers courses as parameters ?

          10x in advance.
          </blockquote>

          Click HELP for text formatting instructions. Then edit this text and check the preview.