문제

I have an image which belongs to a user

class Image {
  static belongsTo = [user: User]
  String name 
  String path
}
class User {
  String name
}

How can I get the user Id without fetching the user in the database :

myService.doIt(Image.get(1).user.id)

fetches the user (I just need the id here)

도움이 되었습니까?

해결책

Use the dynamic "fooId" property for a domain class property "foo":

myService.doIt(Image.get(1).userId)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top