Refactoring to allow Querying with JPA and Relations