In an app based on JPA2/Hibernate/Oracle+Spring+Wicket, I use the following model:
public class Item {
private String name;
private Set<Application> apps;
private ...
}
public class Application {
private String applicant;
private Item item;
private Status status;
private ...
}
The mapping between Item and Application is that every item has many applications, every application points to just one item.
Now I want to search for Applications that satisfy a complex set of criteria and it'd be great if the result set was a set of pairs < Item, List< Application >> (it cannot be just Set< Item >, because usually only a subset of applications for a specific item would satisfy the criteria).
Could you recommend me a way how to do this? My first idea was to query first for pairs < ItemID, AppID > and then iterate through these and produce the result set manually, but it seems quite cumbersome and ineffective.