How to get rid of JpaRepository interfaces in Spring Boot
<p>How do I avoid having a class and an interface per entity when using JPA with Spring Boot?</p>

<p>I have the following entity (and 10 other):</p>

<pre><code>@Entity
@Table(name = "account")
public class Account {

  @Id
  @GeneratedValue
  private Long id;

  @Column(name = "username", nullable = false, unique = true)
  private String username;

  @Column(name = "password", nullable = false)
  private String password;

  ...
</code></pre>

<p>In order to be able to persist this entity, I need to setup an interface per entity:</p>

<pre><code>@Repository
public interface AccountRepository extends JpaRepository&lt;Account, Long&gt; {
}
</code></pre>

<p>and then <code>@autowire</code> it:</p>

<pre><code>@Controller
public class AdminController {

  @Autowired
  AccountRepository accountRepo;

  Account account = new Account();
  account.setUsername(...);
  ...
  accountRepo.save(account);
</code></pre>

<p>If I now have 10 entities, it means that I need to define 10 <code>@Repository</code> interfaces and <code>@autowire</code> each of those 10 interfaces.</p>

<p>How would I embed that save method directly into <code>Account</code> so that I only have to call <code>account.save()</code> and how do I get rid of all those <code>@repository</code> interfaces I have to declare per entity?</p>