I am new to Grails framework and I came across this code
static mapping = {
cache true
}
I know Grails is on Groovy, but I am not understanding how Groovy understands this? Is this a Closure and If yes, the this doesnt seem resemble Closure. As far as I know, if a method is passed a closure it is defined something like this:
def helloWorld = {
println "Hello World"
}
But this static mapping doesnt seem to be Closure as well. How does Grails leverage Groovy to do this ORM mapping? I hope I am articulating my question well!
def mapping{
}
Thanks JSB,So How does Grail pick this mapping? where is this function defined by grails? there must be some place where this closure is ultimately passed? Can I see that so that its clear tp me.does it look something like this
def mapping{
}
In very simple terms Grails considers URL mappings as one of its special kinds of artefacts, like domain classes or controllers and it has means of keeping an eye on the list of mappings for a given application.
When the UrlMappings plugin[1] is loaded it configures a number of beans[2], including UrlMappingsFactoryBean[3]. The latter uses the DefaultUrlMappingEvaluator[4] to interpret all those "mappings" closures and convert them into corresponding UrlMapping instances. You can see what url mappings are registered in an application by inspecting the grailsUrlMappingsHolderBean bean in a Grails console[5].
Hope this helps,
Mihai.
--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/34a74b88-5132-4f16-bd8e-619e75e908b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
My bad.
In that case, you need to look at GrailsValidationApi and friends:
In short, a dedicated validation bean is instantiated for every type of constraint you define in a domain class.
Does this help?
--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/93457457-48ac-4853-9c7e-e7b3763bf25d%40googlegroups.com.