title: Play Framework - Implementing groups with deadbolt2
body: <p>I'm trying to implement deadbolt2 groups, but I am puzzled how I am supposed to achieve this. I am using Play 2.2.1, Deadbolt 2.2.RC4 and Hibernate 4.3.1 with a MySQL database.</p>
  
  <p>I have been able to implement some of Deadbolt:. I can login, register users and annotate methods with <code>@SubjectPresent</code> I would now like to annotate my functions with this: <code>@Restrict(@Group("Administrator"))</code>.</p>
  
  <p>I have been using <a href="https://github.com/schaloner/deadbolt-2-java-examples" rel="nofollow">Deadbolt2-java-example</a> as a guide, but the part concerning groups seems obscure to me.</p>
  
  <p>In the model AuthorisedUser I have: </p>
  
  <pre><code>    @ManyToMany
  public List&lt;SecurityRole&gt;   roles;
  </code></pre>
  
  <p>In my database this creates a table called <code>AuthorisedUser_SecurityRole</code> The problem I have is that I have no idea how I am supposed to query this table. Typing the table name will give me a run-time error. <code>AuthorisedUser_SecurityRole is not mapped</code>. The same applies if I type <code>roles</code></p>
  
  <p>What I am wondering about then is:</p>
  
  <ol>
  <li>How and where do I create new groups?</li>
  <li>How do I retrieve/query the list <code>roles</code> (list of groups a user belongs to) </li>
  <li>How do I add groups to a user?</li>
  </ol>
  
  <p>Please let me know if you need to see any of my code, but I am unsure what you would need to see as most of the code is standard from the deadbolt example.</p>