I want a controller which can take in a mapped entity with varying attributes assigned to it and find an array of similar entities?
Ex: Controller Method
@RequestMapping(value="/get", method=RequestMethod.GET)
public String get(@ModelAttribute("User") User user) {
ArrayList<User> users = repository.someMethod(user);
return users.toString();
}
Going to URL:
localhost:8181/get?name=Bob&ZipCode=35146
returns an ArrayList from the database for all instances of User with name=Bob and ZipCode=35146
Going to URL:
localhost:8181/get?name=Bob&state=Missouri
returns an ArrayList from the database for all instances of User with name=Bob and state=Missouri
Is there a simple Spring (or any other) way of achieving this without a complicated method that chooses from several different queries on the repository with slight deviations?