Search code examples
gwtfilterfilteringrequestfactory

How to filter GWT requestFactory results?


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?


Solution

  • 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.