title: Query method to find from a list
body: <p>I want to get the object from <code>communication</code> table that has Integer x in <code>appointment_type_ids</code>. Can I write a finder method for that?</p>
  <p>Communication.java</p>
  <pre><code>@Getter
  @Setter
  @Entity
  @Table(name = &quot;communication&quot;)
  public class Communication{
  
  
     
      @Column(&quot;id&quot;)
      private Long id;
  
      @Column(&quot;name&quot;)
      private String name;
  
      @Column(&quot;appointment_type_ids&quot;)
      private ArrayList&lt;Integer&gt; appointmentTypeIds;
  
  }
  </code></pre>
  <p>I tried putting <code>List&lt;Communication&gt; findByAppointmentTypeIdsContaining(Integer integer);</code> in the repository, as suggested by @João Dias.
  Following is the error log I get</p>
  <pre><code>Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract java.util.List com.CommunicationRepository.findByAppointmentTypeIdsContaining(java.lang.Integer)! Reason: Failed to create query for method public abstract java.util.List com.CommunicationRepository.findByAppointmentTypeIdsContaining(java.lang.Integer)! unknown collection expression type [org.hibernate.query.criteria.internal.path.SingularAttributePath]; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.CommunicationRepository.findByAppointmentTypeIdsContaining(java.lang.Integer)! unknown collection expression type [org.hibernate.query.criteria.internal.path.SingularAttributePath]
      at org.springframework.data.repository.query.QueryCreationException.create(QueryCreationException.java:101) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:106) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(QueryExecutorMethodInterceptor.java:94) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
      at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) ~[na:na]
      at java.base/java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Collections.java:1056) ~[na:na]
      at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:na]
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
      at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
      at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
      at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.mapMethodsToQuery(QueryExecutorMethodInterceptor.java:96) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$new$0(QueryExecutorMethodInterceptor.java:86) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at java.base/java.util.Optional.map(Optional.java:260) ~[na:na]
      at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.&lt;init&gt;(QueryExecutorMethodInterceptor.java:86) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:360) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:323) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.util.Lazy.getNullable(Lazy.java:230) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.util.Lazy.get(Lazy.java:114) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:329) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845) ~[spring-beans-5.3.8.jar:5.3.8]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) ~[spring-beans-5.3.8.jar:5.3.8]
      ... 44 common frames omitted
  Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.CommunicationRepository.findByAppointmentTypeIdsContaining(java.lang.Integer)! unknown collection expression type [org.hibernate.query.criteria.internal.path.SingularAttributePath]
      at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.&lt;init&gt;(PartTreeJpaQuery.java:96) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:107) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:218) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:81) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:102) ~[spring-data-commons-2.5.2.jar:2.5.2]
      ... 66 common frames omitted
  Caused by: java.lang.IllegalArgumentException: unknown collection expression type [org.hibernate.query.criteria.internal.path.SingularAttributePath]
      at org.hibernate.query.criteria.internal.CriteriaBuilderImpl.isMember(CriteriaBuilderImpl.java:1343) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.springframework.data.jpa.repository.query.JpaQueryCreator$PredicateBuilder.isMember(JpaQueryCreator.java:331) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.JpaQueryCreator$PredicateBuilder.build(JpaQueryCreator.java:290) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.JpaQueryCreator.toPredicate(JpaQueryCreator.java:211) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.JpaQueryCreator.create(JpaQueryCreator.java:124) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.JpaQueryCreator.create(JpaQueryCreator.java:59) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.query.parser.AbstractQueryCreator.createCriteria(AbstractQueryCreator.java:119) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:95) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:81) ~[spring-data-commons-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.&lt;init&gt;(PartTreeJpaQuery.java:217) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$CountQueryPreparer.&lt;init&gt;(PartTreeJpaQuery.java:348) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.&lt;init&gt;(PartTreeJpaQuery.java:91) ~[spring-data-jpa-2.5.2.jar:2.5.2]
      ... 70 common frames omitted
  </code></pre>