Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 1.78 KB

README.md

File metadata and controls

43 lines (27 loc) · 1.78 KB

Vaadin Querydsl prototype

Prototype of Vaadin/Querydsl JPA integration

vaadin-querydsl-prototype provides extensions to the Vaadin JPAContainer methods to support Querydsl types.

QuerydslJPAContainerFactory and QuerydslJPAContainer can be used as replacements for JPAContainerFactory and JPAContainer.

Usage

creation

QuerydslJPAContainer<Person> container = QuerydslJPAContainerFactory.make(Person.class, entityManager);

filtering

// container.addContainerFilter(new Equal("firstName", "Hello"));
// container.addContainerFilter(new Equal("lastName", "World"));
QPerson person = QPerson.person; // Querydsl generated type
container.addContainerFilter(person.firstName.eq("Hello"));
container.addContainerFilter(person.lastName.eq("World"));

filtering and sorting

// container.addContainerFilter(new Equal("firstName", "Hello"));
// container.sort(new Object[] { "firstName" }, new boolean[] { true });
container.addContainerFilter(person.firstName.eq("Hello"));
container.sort(person.firstName.asc());

complex filter

// container.addContainerFilter(new Or(new Equal("firstName", "Hello"), 
                                       new Equal("lastName", "World")));
container.addContainerFilter(person.firstName.eq("Hello")
                             .or(person.lastName.eq("World")));

The commented out code shows the original way to add filters and sorting.

The supported Querydsl operations are and, or, not, like, eq, ne, isNull, startsWith, startsWithIc, contains, between, lt, gt, loe and goe.

This code is just a prototype of a possible integration of Vaadin and Querydsl for JPA querying. It should not be used in production code.