AppEngine:查询数据存储中名称中带有连字符的列

发布于 2024-08-15 20:42:25 字数 300 浏览 11 评论 0原文

我正在 Google App Engine 中开发 servlet。该 servlet 从 GAE 的数据存储中检索数据;当查询“SELECT * FROM...”时,一切正常。但是当我想按某个列过滤它时,它不起作用,因为该列的名称有连字符。如下所示:

Query query = new Query("tableName");
query.addFilter("col-name", Query.FilterOperator.EQUAL, filterValue);

如何传递带有连字符的 propertyName?

I'm working on a servlet in Google App Engine. This servlet retrieves the data from the GAE's datastore; everything works fine when querying like "SELECT * FROM...". But when I want to filter it by a certain column, it does not work since the name of the column has a hypen. It is like the following:

Query query = new Query("tableName");
query.addFilter("col-name", Query.FilterOperator.EQUAL, filterValue);

How do I pass the propertyName with a hyphen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

乖乖公主 2024-08-22 20:42:25

java只接受字母和数字美元符号“$”或下划线字符“_”之类的合法标识符。
所以我相信这是不可能的。在 python 中也不起作用

http://java.sun.com /docs/books/tutorial/java/nutsandbolts/variables.html#naming

java only accepts letters and digits the dollar sign "$", or the underscore character "_" like legal identifiers.
So i believe that's not posible. Also did't work in python

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/variables.html#naming

后来的我们 2024-08-22 20:42:25

AppEngine 数据存储区没有行或列;它有模型和属性。

定义数据类讨论了如何定义模型;需要注意的重要一点是,标识符名称的 Java 规则很重要,因为模型的每个属性在某些时候都会变成具有相同名称的 java 对象。

您自己已经描述过这一点:

如果我按名为的列进行过滤
“field-1”,这就是我正在尝试的
从每个返回值中减去 1
称为字段的列的值

The AppEngine datastore doesn't have rows or columns; it has models and properties.

The Defining Data Classes talks about defining your models; the important thing to note is that the Java rules for identifier names matter, because each property of a model will at some point be turned into a java object with the same name.

You've described this yourself:

if I filter by a column called
"field-1", it is kind of I was trying
to subtract 1 from every returned
value of the column called field

停滞 2024-08-22 20:42:25

addFilter 方法是否正确地将列名称括在单引号中?您可能想尝试自己添加它们。人们可以按 GQL 中数据库中非键的内容进行过滤,因此这可能是您所期望的。

Is the addFilter method correctly enclosing the column name in single quotes? You might want to try adding them yourself. One can filter by things which are not keys in the database in GQL so this might be something that is expected of you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文