title: Grails hasOne relations are really bidirectional?
body: <p>I want to do reflexion on Domain associations to automatically generate a JSON/XML format class descriptor file for a RESTful WS (scaffolding). In the case of HasOne (supposedly bidirectional), I am trying to use the referencedPropertyName in the Association object to show the reverse key (that's the only information that the WS has to show).</p>
  
  <p>Nevertheless I find that hasOne Associations are not correctly initialized. </p>
  
  <p>What follows is the test I made using Grails 2.3.7.</p>
  
  <p>My domains are: </p>
  
  <pre><code>class House {
  
      Long number
      Integer inhabitants
  
      static hasOne = [ roof: Roof ]
      static hasMany = [ doors: Door ]
  
      static constraints = {
          roof nullable: true, unique: true
      }
  }
  
  class Roof {
  
      String color
      House house
  
      static constraints = {
      }
  }
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>import org.grails.datastore.mapping.model.types.Association
  import org.junit.Test
  
  import spock.lang.*
  import test.House
  class AssociationsSpec {
      @Test
      void "test something"() {
          House.gormPersistentEntity.associations.each { Association association -&gt;
              String key = association.name
              println association.properties
              assert association.bidirectional
          }
      }
  }
  </code></pre>
  
  <p>This test fails:</p>
  
  <pre><code>Assertion failed: 
  assert association.bidirectional
         |           |
         |           false
         test.House-&gt;roof
      at test.AssociationsSpec$_test_something_closure1.doCall(AssociationsSpec.groovy:26)
      at test.AssociationsSpec.test something(AssociationsSpec.groovy:23)
  </code></pre>
  
  <p>Additional info (println association.properties):</p>
  
  <pre><code>[list:false, type:interface java.util.Set, owner:org.codehaus.groovy.grails.domain.GrailsDomainClassPersistentEntity@149a797, class:class org.codehaus.groovy.grails.domain.GrailsDomainClassPersistentEntity$5, cascadeOperations:[ALL], inverseSide:test.Door-&gt;house, capitilizedName:Doors, bidirectional:true, referencedPropertyName:house, associatedEntity:org.codehaus.groovy.grails.domain.GrailsDomainClassPersistentEntity@99a9c3, mapping:null, circular:false, owningSide:true, name:doors, fetchStrategy:EAGER]
  
  [capitilizedName:Roof, bidirectional:false, referencedPropertyName:null, circular:false, owningSide:true, name:roof, list:false, type:class test.Roof, owner:org.codehaus.groovy.grails.domain.GrailsDomainClassPersistentEntity@149a797, class:class org.codehaus.groovy.grails.domain.GrailsDomainClassPersistentEntity$4, cascadeOperations:[ALL], inverseSide:null, associatedEntity:org.codehaus.groovy.grails.domain.GrailsDomainClassPersistentEntity@16289cc, mapping:null, foreignKeyInChild:true, fetchStrategy:EAGER]
  </code></pre>
  
  <p>Thank you</p>