douglasom opened a new issue, #14362:
URL: https://github.com/apache/grails-core/issues/14362

   Nested objects have to be set as "embedded" to be persisted even when they 
are all in src/main/groovy. I believe non entity classes should always be saved 
as embedded objects. Above all, non entity objects should never have to have 
`static embedded` declarations.
   
   The following test only pass when the commented lines get uncommented. I 
believe it would be more appropriate if it passed even without those commented 
lines.
   
   ```package org.grails.datastore.gorm.mongo
   
   import grails.gorm.tests.GormDatastoreSpec
   import grails.persistence.Entity
   
   class EmbeddedWithinEmbeddedSimpleObjectSpec extends GormDatastoreSpec {
   
       void "Test embedded nested non-domain object"() {
           when:"An entity with a simple nested non-domain embedded object is 
persisted"
               def constellation = new Constellation(displayName: "foo", 
solarSystem: new SolarSystem(planet: new Planet(name: "earth")))
               constellation.save(flush:true)
               session.clear()
               constellation = Constellation.get(constellation.id)
           then:"The embedded association is persisted correctly"
               constellation.solarSystem?.planet?.name == 'earth'
       }
   
       @Override
       List getDomainClasses() {
           [Constellation]
       }
   }
   
   @Entity
   class Constellation {
   
       String id
       String displayName
   
       SolarSystem solarSystem
   
       static embedded = [ 'solarSystem' ]
   }
   
   //@Entity
   class SolarSystem {
       Planet planet
   
   //    static embedded = [ 'planet' ]
   }
   
   //@Entity
   class Planet {
       String name
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to