Using the map automatic creation on domain classes doesn't fill in transient properties:
class Address {
String street
String number
static transients = ["number"]
}
def address = new Address(street: "King's Street", number: "23")
println address.street //King's Street
println address.number //null
Is there any good reason for that? Grails domain instantiation overrides the default Groovy behaviour?
You can do it by two-way.
If you want to make transient a field, you need to bind it.
class Address {
String street
String number
static constraints = {
number bindable: true, nullable:true
}
static transients = ['number']
}
You can bind it using some getter method.
class Address {
String street
String number
String getDifferentNumber() { number }
static transients = ['differentNumber']
}
Hope it will help you. Enjoy.