title: Making transactional calls to the DB when using UserDetailsService
body: <p>I have a User class marked as entity which also implements UserDetails. I want to be able to grab some properties of a certain user, and based on their values, to return specific roles in the <code>getAuthorities</code> method. Many of those properties are however lazy-loaded and require a  Hibernate transaction. </p>
  
  <p>I tried anything from making the user class <code>@Transactional</code> to making the <code>UserDetailsService</code> and <code>RememberMeService</code> which I use <code>@Transactional</code>. None of those works!</p>
  
  <p>All of my other DAO and Service classes mapped as transactional work (and they are just simple classes - no other annotations besides a @Transactional on top)</p>
  
  <p>UPDATE: This is the overriden getUserDetails in class User</p>
  
  <pre><code>@Override
      public Collection&lt;? extends GrantedAuthority&gt; getAuthorities() {
  
          GrantedAuthority auth = new GrantedAuthority() {
  
              @Override
              public String getAuthority() {
                  // TODO Auto-generated method stub
                  return "ROLE_USER";
              }
          };
  
          ArrayList&lt;GrantedAuthority&gt; result = new ArrayList&lt;GrantedAuthority&gt;();
  
          if (options.size() &gt; 0) {
              for (Option o : options) {
                  result.add(createAuthority(Option.getStringType(o.type)));
              }
          }
  
          result.add(auth);
  
          return result;
  
      }
  </code></pre>