title: Named query when property is an object?
body: <p>I would like to make this query in JPA:</p>
  
  <pre><code>SELECT * FROM `happyDB`.`users` U WHERE U.party_as_user =1 AND U.party_party_id =2
  </code></pre>
  
  <p>This is working fine, but my problem is that I have <code>Party</code> only as an object, not as an id and I can't make it work.</p>
  
  <p>In the <code>Users</code>-entity where I am trying to do the named query I have the following:</p>
  
  <pre><code>@JoinColumn(name = "pary_party_id", referencedColumnName = "party_id")
  @ManyToOne
  private Party partyId;
  
  @Column(name = "party_as_user")
  private Boolean partyAsUser;
  </code></pre>
  
  <p>I tried to implement it like an object with dot notation, but that's not working:</p>
  
  <pre><code>@NamedQuery(name = "Users.findByPartyAsUser", query = "SELECT u FROM Users u WHERE u.partyAsUser = :partyAsUser AND u.partyId.partyId = :partyId")
  </code></pre>
  
  <p>There is a property called <code>partyId</code> inside the <code>Party</code>-object, but it's not working. Is there any solution for that or do I have to add one property to the Users-bean like <code>private int partyID</code> and populate it every time when a new <code>Party</code> is inserted into <code>Users</code>?</p>
  
  <p>Thanks for helping!
  Sami Nurmi</p>