Switched query builder to Java