如何通过 WHERE 子句访问相关 table 的属性?

How to get access to properties of related table via WHERE clause?

例如我有以下域名:

class Company {
    String name 
}

class Employee {
    String firstName
    String secondName
    Company company
}

并且我尝试获取公司名称为 'M$oft'

的所有员工
Employee.where {
   eq 'company.name', 'M$oft'
}.list()

得到:

could not resolve property: company.name of: myapp.Employee


我也试试这个:

Employee.where {
   createAlias('company', 'c')
   eq 'c.name', 'M$oft'
}.list()

得到:

could not resolve property: c of: myapp.Employee


我知道:

Employee.where {
    company.name == 'M$oft'
}

但它不适合我。

我只想知道:是否可以通过 where 子句使用字段的字符串名称来实现?

使用下一个语法:

 Employee.where {
   company{
     eq 'name', 'M$oft'
   }
}.list()

并且不要忘记将 ' ' 与包含 $.可能会有一些意想不到的结果。