title: LIKE - hibernate named queries
body: <p>why I get <strong>syntax error</strong> using this named query :</p>
  
  <pre><code>@NamedQuery(name = "event_find", query = "from Event where location.address like str('%'+:address+'%') " +
          "or :address like str('%'+location.address+'%'")
  </code></pre>
  
  <p>and :</p>
  
  <pre><code>Query query = session.getNamedQuery("event_find").setParameter("address", address); // or "%"+address+"%"
  </code></pre>
  
  <p>how can I solve this problem?</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>Event :</p>
  
  <pre><code>@NamedQueries({
          @NamedQuery(name = "event_find", query = "from Event where location.address like :address " +
          "or :address like location.address")
  })
  @Entity
  @Table(catalog = "control_station")
  public final class Event implements Serializable {
  
      private long id;
      private Location location;
      ...
  
      @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
      public Location getLocation() {
          return location;
      }
  
      public void setLocation(Location location) {
          this.location = location;
      }
  
      ...
  
  }
  </code></pre>
  
  <p>Location :</p>
  
  <pre><code>@Entity
  @Table(catalog = "control_station")
  public final class Location implements Serializable {
  
      private long id;
      private String address;
      private double latitude;
      private double longitude;
  
      ...
  }
  </code></pre>
  
  <p>for example suppose we have three addresses in table <code>Location</code> :</p>
  
  <ol>
  <li>Spain</li>
  <li>Madrid, Spain</li>
  <li>Santiago Bernabeu Stadium, Madrid, Spain</li>
  </ol>
  
  <p>now if I search for <strong>Madrid, Spain</strong>, the result must contains all of the above...</p>
  
  <p>i.e : </p>
  
  <p>where <strong>Spain</strong> like <strong>%Madrid, Spain%</strong> or <strong>Madrid, Spain</strong> like <strong>%Spain%</strong></p>
  
  <p>where <strong>Santiago Bernabeu Stadium, Madrid, Spain</strong> like <strong>%Madrid, Spain%</strong> or <strong>Madrid, Spain</strong> like <strong>%Santiago Bernabeu Stadium, Madrid, Spain%</strong></p>
  
  <p>and so on...</p>