<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello,</p>
    <p>you're right. The <not> clause doesn't work well (or maybe
      doesn't work at all) with multivalued items. The reason is that
      the translation of such queries to HQL/SQL is not so
      straightforward. Some kind of embedded query or something like
      that would be needed. You could create a JIRA for this if you
      want, but I am not sure when we'll have some time to implement
      that.<br>
    </p>
    <p>And yes, I know that the query interpreter (i.e. the code that
      translates midPoint queries to HQL queries) could be more polite
      and explain errors in a better way... again, not enough time for
      that. :-)<br>
    </p>
    <p>Best regards,</p>
    <pre class="moz-signature" cols="72">Pavol Mederly
Software developer
evolveum.com
</pre>
    <div class="moz-cite-prefix">On 02.10.2017 23:17, Alcides Carlos de
      Moraes Neto wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAMLLNmnKq1ZNO_f3gLYfcdBv7DtMP3JKbRB4GYiufqQxVN6Yiw@mail.gmail.com">
      <div dir="ltr">So, this only happens with multivalued fields.
        Single valued fields work just fine. Is this as intended? </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">2017-09-28 18:51 GMT-03:00 Alcides
          Carlos de Moraes Neto <span dir="ltr"><<a
              href="mailto:alcides.neto@gmail.com" target="_blank"
              moz-do-not-send="true">alcides.neto@gmail.com</a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Hello all,
              <div><br>
              </div>
              <div>I'm trying to make a simple search query. I want to
                find all users with an assignment, that don't have XYZ
                value for organizational unit.</div>
              <div><br>
              </div>
              <div>I can do this just fine:</div>
              <div>
                <div><query></div>
                <div>    <filter></div>
                <div>        <and></div>
                <div>            <ref></div>
                <div>               
                  <path>assignment/targetRef</<wbr>path></div>
                <div>                <value
                  oid="7d66fc64-1540-44da-8f3d-<wbr>c565bc917e12"/></div>
                <div>            </ref></div>
                <div>            <equal></div>
                <div>                <path>organizationalUnit</<wbr>path></div>
                <div>                <value>XYZ</value></div>
                <div>            </equal></div>
                <div>        </and></div>
                <div>    </filter></div>
                <div></query></div>
              </div>
              <div><br>
              </div>
              <div>This will fetch users with the assignment and the
                value organizationalUnit XYZ</div>
              <div><br>
              </div>
              <div>If I add the <not>...</div>
              <div>
                <div><query></div>
                <div>    <filter></div>
                <div>        <and></div>
                <div>            <ref></div>
                <div>               
                  <path>assignment/targetRef</<wbr>path></div>
                <div>                <value
                  oid="7d66fc64-1540-44da-8f3d-<wbr>c565bc917e12"/></div>
                <div>            </ref></div>
                <div>            <not></div>
                <div>              <equal></div>
                <div>                 
                  <path>organizationalUnit</<wbr>path></div>
                <div>                  <value>NQPPPS</value></div>
                <div>              </equal></div>
                            </not>
                <div>        </and></div>
                <div>    </filter></div>
                <div></query></div>
              </div>
              <div><br>
              </div>
              <div><br>
              </div>
              <div>This results in a hibernate error:</div>
              <div><span style="color:rgb(51,51,51);font-family:monospace;font-size:11px;white-space:pre-wrap">org.hibernate.<wbr>HibernateException: SqlNode's text did not reference expected number of columns
        at org.hibernate.hql.internal.<wbr>ast.tree.<wbr>AbstractNullnessCheckNode.<wbr>extractMutationTexts(<wbr>AbstractNullnessCheckNode.<wbr>java:151)</span><br>
              </div>
              <div>...</div>
              <div><span style="color:rgb(51,51,51);font-family:monospace;font-size:11px;white-space:pre-wrap">at com.evolveum.midpoint.repo.<wbr>sql.query2.hqm.<wbr>RootHibernateQuery.<wbr>getAsHqlQuery(<wbr>RootHibernateQuery.java:96)</span><br>
              </div>
              <div><br>
              </div>
              <div>Am I doing something wrong? Is it a bug? I'm using
                midpoint 3.6</div>
              <div>Is there any other way to get what I want from a
                query?<br>
              </div>
              <div><br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>