上面的例子中传递给查询的值是硬编码的,但是,你可以同样地使用位置参数:def results =
Book.findAll("from Book as b where b.title like ?", ["The Shi%"])
或者甚至使用命名参数:def results =
Book.findAll("from Book as b where b.title like :search or b.author like :search", [search:"The Shi%"])
上面的例子中传递给查询的值是硬编码的,但是,你可以同样地使用位置参数:def results =
Book.findAll("from Book as b where b.title like ?", ["The Shi%"])
或者甚至使用命名参数:def results =
Book.findAll("from Book as b where b.title like :search or b.author like :search", [search:"The Shi%"])