title: How to use @Where in Hibernate
body: <p>Searched for a few hours, but I'm stuck in a my learning curve for PlayFramework with JPA. I'm building a sample website where posts can be made. But these posts can have the states:</p>
  
  <ul>
  <li>PostDraft (post is a draft, do not publish)</li>
  <li>PostPublished (post can be published)</li>
  </ul>
  
  <p>These states are stored in a seperate table. Obviously, the draft state posts <strong>should not be visible yet.</strong></p>
  
  <p>So I have these classes:</p>
  
  <ul>
  <li>Page class (getting the page information from table, 1 page can have multiple posts)</li>
  <li>Posts class (posts can be in draft and published)</li>
  </ul>
  
  <p>In my page class I have:</p>
  
  <pre><code>@Column(name="POSTS_REF")
  @Where(clause="PostPublished")
  private List&lt;Posts&gt; userPosts;
  </code></pre>
  
  <p>But this is not working! So, how can I specifify a where clause, to load only the posts that are in published state without using JPQL??</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE: 2011-10-11</strong></p>
  
  <p>Table: <em>Posts</em> with columns:
   - id
   - title
   - state_ref  (reference to the ID of States table)
   - content</p>
  
  <p>Table: <em>States</em> with columns:
   - id
   - statename</p>
  
  <p>So I want to say something like:</p>
  
  <pre><code>select * 
  from posts inner join states on posts.state_ref = states.id
  where states.statename = 'PostPublished'
  </code></pre>
  
  <p><strong>UPDATE 2011-10-13</strong></p>
  
  <p>This is my current modification, in my page class: but it does not work either.</p>
  
  <pre><code>/** link to the states */
  @JoinColumn(name = "STATES_REF")
  @OneToOne
  @Where(clause = "states.statename = 'PostPublished'")
  public MyState state;
  </code></pre>
  
  <p><strong>UPDATE 2012-02-13</strong>
  Emt's answer worked for me after all.</p>