在 Apache Cayenne 文档中,他们提供了一个示例,说明如何使用 Expression 类的 fromString() 函数创建参数化查询:
// create a qualifier with two named parameters: "pname" and "aname"
Expression qual = Expression.fromString("paintingTitle = $pname or toArtist.artistName = $aname");
// build a query prototype of a query - simply another select query
SelectQuery proto = new SelectQuery(Painting.class, qual);
进行这样的查询非常简单,除了一个问题:文档没有解释 $pname 和 $aname 是什么或如何将它们设置为您要查询的值!
谁能解释如何设置这些参数???请指教...