Type-safe queries for Java