保存域对象后如何获取 id?

How do you get the id after saving a domain object?

如何获取已保存对象的 ID。

请给我一个主意。因为我是 grails 的初学者

 def saveCandidates(){
            def candidate=new Candidates(
                    name: request.getParameter('name'),
                    email: request.getParameter('email'),
                    mobile: request.getParameter('mobile')
            )
            candidate.save()
    //how i can get of candidate
           redirect(uri: request.getHeader('referer'))
            //redirect(url: request.header('referer'))
        }

保存域后

def candidate = new Candidates(
                name: params.name,
                email: params.email,
                mobile: params.mobile)

candidate.save()

你可以通过

访问这个id
candidate.id