Spring data repository's method to find by the field of a field
<p>I've two entities, a user and a registered user. </p>

<p>A registered user has a field of type user. I would like to have a method in the spring data repository related to this registered user entity to search all registered users by the username of the user that is connected to the registered user.</p>

<p>So, this is the registered user entity with an associated user field:</p>

<pre><code>@Entity
public class RegisteredUser implements Serializable {

    ... 
    @OneToOne
    @JoinColumn(name = "USERNAME_FK")
    private User user;
    ...
}
</code></pre>

<p>and this is a user with a username:</p>

<pre><code>@Entity
public class User implements Serializable { 
    ...
    @Id
    @Column(nullable = false)
    protected String username;
    ...
}
</code></pre>