0 Replies Latest reply on Nov 20, 2013 2:50 PM by nicolas duminil

    How to use a "not exists" subquery in RESTRICTIONS ?

    nicolas duminil Master

      Greetings,

       

      Using Seam 2.2.6. I need to perform the following query:

       

      select a from T1 where a.f1 <> some_value and not exists (select * from t2 where t2.f2 <> t1.f1);

       

      I tried the following:

       

        private static final String EJBQL = "select t1 from T1 t1 where not exist s (select t2 from T2 t2 where t1.f1 != t2.f2)";

        private static final String[] RESTRICTIONS = {"event.eventId != #{eventHome.instance.eventId}"};

       

      The generated query is something like:

       

      select a from T1 where a.f1 <> some_value and not (exists (select * from t2 where t2.f2 <> t1.f1);

       

      and it raises a syntax error because of the unbalanced paranthese between not and exists.

       

      I tried also as follows:

       

        private static final String EJBQL = "select t1 from T1 t1 ";

        private static final String[] RESTRICTIONS = {"event.eventId != #{eventHome.instance.eventId}", "not exists (select t2 from T2 t2 where t1.f1 != t2.f2}";

       

      and in this case I have an exception saying that there must be one binding by restriction, i.e.each restriction must contain an expresion like #{...}.

       

      I googled a lot but without any example other then the most simple ones.

       

      Please help. Many thanks in advance,

       

      Nicolas