spring - GORM global beforeInsert to set modifiedBy -


i want set modifiedby , createdby properties of domainclasses automaticly. changed bootstrap.grooy this:

import org.codehaus.groovy.grails.commons.grailsdomainclass  class bootstrap { def grailsapplication  def init = { servletcontext ->     grailsapplication.domainclasses.each { grailsdomainclass gdc ->         if (gdc.hasproperty('modifiedby') && gdc.hasproperty('createdby')) {             gdc.metaclass.beforeinsert = {                 modifiedby = springsecurityservice.currentuser.id                 createdby = springsecurityservice.currentuser.id             }         }         if (gdc.hasproperty('modifiedby') && gdc.hasproperty('modified')) {             gdc.metaclass.beforeupdate = {                 modified = new date()                 modifiedby = springsecurityservice.currentuser.id             }         }       }    }   } 

to work need springsecurityservice in domainclasses have properties, add this:

def springsecurityservice static transients = ['springsecurityservice'] 

how can inject springsecurityservice without that?

i found solution in this

this works platform plugin


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -