title: Spring Roo, Hibernate, One to many relation creates additional table
body: <p>I'm new to spring mvc, roo and hibernate.</p>
  
  <p>I'm trying to create two tables with 1:M relationship.</p>
  
  <p>For example,
  I want two entities, Person and Car. One person can have many cars.</p>
  
  <p>I've created entities using Roo</p>
  
  <pre><code>entity --class ~.domain.Person
  field string Name
  entity --class ~.domain.Car
  field string Name
  field reference --fieldName owner --type ~.domain.Person
  field set --fieldName ownedCars --type ~.domain.Car --class ~.domain.Person --cardinality ONE_TO_MANY 
  </code></pre>
  
  <p>Generated class for car:</p>
  
  <pre><code>@RooJavaBean
  @RooToString
  @RooEntity
  public class Car {
  
      private String Name;
  
      @ManyToOne
      private Person owner;
  }
  </code></pre>
  
  <p>Generated class for Person</p>
  
  <pre><code>@RooJavaBean
  @RooToString
  @RooEntity
  public class Person {
  
      private String Name;
  
      @OneToMany(cascade = CascadeType.ALL)
      private Set&lt;Car&gt; ownedCars = new HashSet&lt;Car&gt;();
  }
  </code></pre>
  
  <p>However, in the database, there are 3 tables (insted of two)</p>
  
  <p>Table CAR (as expected)</p>
  
  <pre><code>  CREATE TABLE "TEST"."CAR" 
     (    
      "ID" NUMBER(19,0), 
      "NAME" VARCHAR2(255 BYTE), 
      "VERSION" NUMBER(10,0), 
      "OWNER" NUMBER(19,0)
     )
  </code></pre>
  
  <p>Table PERSON (as expected)</p>
  
  <pre><code>  CREATE TABLE "TEST"."PERSON" 
     (
  "ID" NUMBER(19,0), 
      "NAME" VARCHAR2(255 BYTE), 
      "VERSION" NUMBER(10,0)
     )
  </code></pre>
  
  <p>and also PERSON_OWNED_CARS (which is not expected, it's not many to many relationship)</p>
  
  <pre><code>  CREATE TABLE "TEST"."PERSON_OWNED_CARS" 
     (
  "PERSON" NUMBER(19,0), 
      "OWNED_CARS" NUMBER(19,0)
     )
  </code></pre>
  
  <p>Why is the last table generated? What is the purpose of the last table, it's not many to many relationship? Can it be avoided? Am I doing something wrong?</p>