You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
}
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: