I am running into the same problem, applying Predicates, Orders and other manipulations on composite ID's is very cumbersome because of this.
A simple piece of code, like this:
Code:
Root<ProjectActivity> root = query.from(ProjectActivity.class);
query.multiselect(root.get("projectId"), root.get("projectActivityId"), root.get("name"));
turns into a big chunck of code:
Code:
Root<ProjectActivity> root = query.from(ProjectActivity.class);
EntityType<ProjectActivity> et = e.getMetamodel().entity(ProjectActivity.class);
Path<?>[] attributes = new Path<?>[3];
for(SingularAttribute<? super ProjectActivity, ?> s : et.getIdClassAttributes()){
if(s.getName().equals("projectId"))
attributes[0] = root.get(s);
if(s.getName().equals("projectActivityId"))
attributes[1] = root.get(s);
}
attributes[2] = root.get("name");
query.multiselect(attributes);
Any ideas on how to deal with this?