title: Use array_position with JPA Criteria API?
body: <p>I am using springjpa &amp; postgresql,there is a field in my database which is bitint array type,And in Java,it is a Long value.</p>
  
  <p>I am using spring jpa CriteriaBuilder&amp;Specification to make a array position function :</p>
  
  <pre><code>private Predicate toPredicate(String propName, Query q, Root&lt;T&gt; root, CriteriaBuilder cb) {
      ...
      return cb.isNotNull(cb.function("array_position", Integer.class,
                              xx expression,
                              cb.literal(q.value)));  // q.value is a long type value
  }
  
  </code></pre>
  
  <p>And it goes error when i execution query:</p>
  
  <pre><code>Hibernate: 
      select
          distinct ruletemp0_.id as id1_119_,
          ruletemp0_.applicant as applican2_119_,
          ruletemp0_.approver as approver3_119_,
          ruletemp0_.devices as devices4_119_,
          ruletemp0_.end_time as end_time5_119_,
          ruletemp0_.execution_id as executio6_119_,
          ruletemp0_.execution_type as executio7_119_,
          ruletemp0_.extra as extra8_119_,
          ruletemp0_.rule_id as rule_id9_119_,
          ruletemp0_.start_time as start_t10_119_,
          ruletemp0_.state as state11_119_,
          ruletemp0_.user_id as user_id12_119_ 
      from
          tbl_ruletemp ruletemp0_ 
      where
          array_position(ruletemp0_.user_id, 1) is not null 
          or array_position(ruletemp0_.user_id, 2) is not null
  2019-10-30 10:44:42.230 [WARN ] [main] [org.hibernate.engine.jdbc.spi.SqlExceptionHelper::logExceptions] SQL Error: 0, SQLState: 42883
  2019-10-30 10:44:42.230 [ERROR] [main] [org.hibernate.engine.jdbc.spi.SqlExceptionHelper::logExceptions] ERROR: function array_position(bigint[], integer) does not exist
    建议：No function matches the given name and argument types. You might need to add explicit type casts.
  
  </code></pre>
  
  <p>It seems jpa does not recognize my Long type value,i try to use:</p>
  
  <pre><code>BigInteger bigInteger = new BigInteger(String.valueOf(q.value));
  return cb.isNotNull(cb.function("array_position", Integer.class,
                              toExpression(propName, root),
                              cb.literal(bigInteger)));                    
  </code></pre>
  
  <p>Still error.
  If i execute SQL query in pg directly :</p>
  
  <pre><code>select * from tbl_ruletemp t where array_position(t.user_id, cast(1 as BIGINT)) is not null;
  </code></pre>
  
  <p>will work.</p>
  
  <p>And ideas?</p>