title: How do I insert data into 2 tables in the same database using Spring Boot Crudrepository?
body: <p>I want to be able to create a new account for my application. I have an account class which represents one entity and another class that represents personal information of the account. In order to create the new account and have it be in the database I want to add some information into the account table and some information into the PersonalInfo table as detailed in the classes below. How do I do this with a CrudRespository interface. As I understand it, the crudrepository can interact with one table in the database. In my example that would be Accounts. This is fine because most of my checking and communicating will be with the accounts table. But for when I am creating a new account I need to add the data that will be given into two tables. Do I have to make manual queries and add it as a method in there?</p>
  <pre><code>@Entity
  @Component
  public class Account {
      
      @Id
      private int accountNum;
      
      private String accountType;
      private int accountBalance;
      private String accountStatus;
  </code></pre>
  <pre><code>@Entity
  @Component
  public class PersonalInfo {
      
      @Id
      private int accountNum;
      
      private String firstName;
      private String lastName;
      private String SSN;
      private String streetName;
      private String city;
      private String state;
      private String zipcode;
  </code></pre>
  <pre><code>@RepositoryRestResource(collectionResourceRel=&quot;accounts&quot;,path=&quot;accounts&quot;)
  public interface AccountsDB extends CrudRepository&lt;Account, Integer&gt;{
  
  }
  </code></pre>