Skip to content

Instantly share code, notes, and snippets.

@dhanji
Created November 4, 2012 22:51
Show Gist options
  • Save dhanji/4014182 to your computer and use it in GitHub Desktop.
Save dhanji/4014182 to your computer and use it in GitHub Desktop.
Completely type-safe query-DSL for Java
Person p = query.topic(Person.class);
List<Person> results = query.from(p)
.where(p.getName(), is("Jason"))
.and(p.getAge(), greaterThan(10))
.and(p.getCountry(), like("Canad*"))
.or()
.where(p.getName(), is("Dhanji"))
.and(p.getCountry(), not("Canada"))
.list();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment