if (query.isObjectLevelReadQuery()) {
if(valueToApply != null) {
if (valueToApply instanceof String){
AttributeGroup eg = activeSession.getAttributeGroups().get(valueToApply);
if (eg != null){
((ObjectLevelReadQuery)query).setLoadGroup(eg.toLoadGroup());
}else{
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("no_entity_graph_of_name", new Object[]{valueToApply}));
}
}else if (valueToApply instanceof EntityGraphImpl){
((ObjectLevelReadQuery)query).setLoadGroup(((EntityGraphImpl)valueToApply).getAttributeGroup().toLoadGroup());