如何过滤GWT requestFactory结果?
我有一个关于如何在 GWT 中使用 RequestFactory 进行数据过滤的问题。我目前正在开发一个由 MySQL 数据库支持的应用程序。我的持久层基于 JPA/Hibernate。我正在使用 RequestFactory 查询数据库以获取所有与列表相关的操作。
例如,我有一个 Person 对象:在我的 PersonRequestContext 中,我有一个允许我列出人员的方法。方法签名是:
Request<List<PersonProxy>> listPersons(Integer firstResult, Integer maxResults);
正如您可能已经猜到的,相应的查询是这样的:
entityManager.createQuery("SELECT p FROM Person p ORDER BY p.id").setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
现在,我想根据表列过滤结果。所以我想使用某种 Filter 类抽象来解决它。问题是,众所周知,不可能将非原始对象传递给 requestFactory 方法。
你经历过这样的事情吗?以及你是如何处理来解决这个问题的?
I have a question about how to do data filtering with RequestFactory in GWT. I am currently working on an application which is backed by a MySQL database. My persistence layer is based on JPA/Hibernate. I am using RequestFactory to query my database for all my listing-related operations.
So for example, I have a Person object : In my PersonRequestContext I have a method which allows me to list persons. The method signature is :
Request<List<PersonProxy>> listPersons(Integer firstResult, Integer maxResults);
As you may have guessed, the corresponding query is something like this :
entityManager.createQuery("SELECT p FROM Person p ORDER BY p.id").setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
Now, I would like to filter the result based on table columns. So I wanted to use some kind of Filter class abstraction to solve it. The problem is that as we all know, it's not possible to pass non-primitive objects in to the requestFactory method.
Have you ever experienced this kind of thing ? And how did you deal with it to solve the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您关于只有原始类型可以传递给 Request 方法的断言是不正确的。请参阅有关可传输类型的文档。您可以创建一个
ValueProxy
层次结构来对过滤器进行建模。Your assertion that only primitive types can be passed to a Request method is incorrect. See the documentation on transportable types. You can create a
ValueProxy
hierarchy to model your filters.