数据存储中带有日语字符的命名参数不起作用
我正在开发 Google Web Toolkit 应用程序,并使用 JPA 来访问数据存储区。 我刚刚发现以下方法不起作用:
Query q = manager.createQuery("select x from Question x where x.name=:name");
q.setParameter("name", "ト<br />");
q.getResultList();
这会返回 0 个结果。 但不使用命名参数确实有效:
Query q = manager.createQuery("select x from Question x where x.name='ト<br />'");
q.getResultList();
这会返回 2 个结果,这是正确的。也许它与假名符号(to)有关,但无论如何它看起来都像一个错误。有没有人也经历过这个,这是一个已知的错误,还是我做错了什么?我想我可以避免命名参数,但我宁愿不这样做。
编辑:删除了示例中不存在于我的原始代码中的拼写错误
I am working on a Google Web Toolkit application, and I use JPA for access to the datastore.
I just found out that the following doesn't work:
Query q = manager.createQuery("select x from Question x where x.name=:name");
q.setParameter("name", "ト<br />");
q.getResultList();
This returns 0 results.
But not using named parameters does work:
Query q = manager.createQuery("select x from Question x where x.name='ト<br />'");
q.getResultList();
This returns 2 results, which is correct. Perhaps it has to do with the kana symbol (ト), but it looks like a bug anyway. Has anyone experienced this as well, is it a known bug, or am i doing something wrong? I guess i could just avoid named parameters, but i rather not.
Edit: removed typo in example that wasn't present in my original code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是绑定变量的编码。
检查编码配置,这方面可能取决于数据存储。
再见
problem is encoding for binding variable.
Check encoding configuration, this aspect could depend from datastore.
bye
你试过这个吗:
?
我想你不需要参数名称中的“:”。
您可能需要阅读此文档。
Did you tried this:
?
I guess you don't need the ":" in the parameter name.
You may want to read this doc.