title: Hibernate Query filter by Regex expression
body: <p>I have an entity which has a pattern column. What would be the best way to find an existing record based on which pattern matches a given string?</p>
  
  <p>For example:</p>
  
  <h3>Table records</h3>
  
  <pre><code>| ID | pattern |
  | 1  | /actions/{action-id:\d+}/{type-id:\d+}/{edge:[a-z][\w]+}/draft |,
  | 2  | /actions/{action-id:\d+}/{edge:[a-z][\w]+}/submit |,
  | 3  | /actions/{action-id:\d+}/{type-id:\d+}/{edge:[a-z][\w]+}/request |,
  | 4  | /actions/{action-id:\d+}/{edge:[a-z][\w]+}/request |,
  | 5  | /actions/{action-id:\d+}/{edge:[a-z][\w]+}/terminate |
  </code></pre>
  
  <h3>Input String</h3>
  
  <pre><code>/actions/1/send/request
  </code></pre>
  
  <p>This would return the <code>Action</code> record with <code>ID = 4</code> as the pattern <code>/actions/{action-id:\d+}/{edge:[a-z][\w]+}/request</code> matches the input string.</p>
  
  <p>Which is the most perfomant way to achieve this?</p>
  
  <blockquote>
    <p>Note: It's guaranteed that the input string will match <strong>only one</strong>
    pattern in the table</p>
  </blockquote>
  
  <p>.</p>
  
  <p>Thanks.</p>