title: Many-to-Many link tables in grails (GORM) / hibernate
body: <p>I'm playing aroud with Grails and am finding the ORM stuff tedious because I don't fully understand what I'm doing when it comes to domain classes. I'm hoping someone can put me back on track</p>
  
  <p>Consider the following</p>
  
  <p>Test Job  <strong>One:Many</strong>   Hardware Used on Job    <strong>Many:One</strong>     Physical Hardware</p>
  
  <p>...this is analogous to the classic Order, OrderLine, Product scenario seen in university DB examples</p>
  
  <p>I've created the following domain classes</p>
  
  <pre><code>class Job
  {
    String jobName
    String jobDescription
  }
  
  class HardwareOnJob
  {
     static hasMany = [  jobs:Job, physicalHardware:PhysicalHardware ]
     static belongsTo = Job
  
     String role
  }
  
  class PhysicalHardware
  {
    String assetName
    String model
    String os 
  }
  </code></pre>
  
  <p>The question I need to ask is why does Grails create me two extra tables in my database rather than using the link entity/domain class I've defined. For instance Grails creates hardware_on_job_job and hardware_on_job_physical_hardware in the database. </p>
  
  <p>Using the scaffolded controllers I can enter some hardware, enter a job and then enter link the two together. The question I have is why does it create these two extra tables rather than use the domain object (HardwareOnJob) I've specified. </p>
  
  <p>Any help/guidance would be very much appreciated as going nuts looking at this and trying new things. Btw I'm on grails version 1.2.1</p>