title: Spring : How to retrieve set of entities using JpaRepository method without using the primary key?
body: <p>I want to retrieve list of entities for a given id from my database. But this id is not the primary key of my table. </p>
  
  <pre><code>public List&lt;Notification&gt; view(ApplicationUser applicationUser){
      List&lt;Notification&gt; notification = repository.findAll();  
  
      return notification;
  }
  </code></pre>
  
  <p>In my code I have a applicationUser ID which is NOT the primary key of notification table. It is only a foreign key. In the above case I can retrieve the entire table. I tried repository.getOne() method as well. but my requirement can not be full filled with that.</p>
  
  <p>I want to get all the entities to the notification list where appliclationUserId field of my table is equal to the user provided value. </p>
  
  <p>Here is my notification table</p>
  
  <pre><code>CREATE TABLE `notification` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (`id`),
    `message` varchar(100),
    `dateAndTime` time DEFAULT NULL,
    `read` tinyint(1) NOT NULL DEFAULT '0',
    `notificationType` int(11) DEFAULT NULL
    `userId` bigint(20),
    FOREIGN KEY (`userId`) REFERENCES `application_user` (`id`)
  );
  </code></pre>
  
  <p>Any help is highly appreciated.z</p>