title: Retrieve without using the id in JPA
body: <p>I have a table:</p>
  
  <pre><code>User: id, name, age, role_key
  </code></pre>
  
  <p>where Id is the unique identifier.
  I want to retrieve all the users with a particular role_key. </p>
  
  <p>I could do something like this:</p>
  
  <pre><code>entityManager.createQuery(
      "SELECT u From user WHERE user.role_key LIKE :roleKey")
      .setParameter("roleKey", roleKey)
      .getResultList();
  </code></pre>
  
  <p>But I wanted to know if there is a better way to write the query. 
  For example, if I wanted to retrieve by just using Id, I could have used <code>find</code>. But, since I am using role_key which is not unique, is there a way that I need not write the complete select query here.</p>
  
  <p>Thanks</p>