@Override public Session findSessionById(long id, ServiceFactory sf) { final LocalQuery iQuery = (LocalQuery) sf.getQueryService(); final String sessionClass = iQuery.find(Share.class, id) == null ? "Session" : "Share"; return (Session) iQuery.findByQuery( "select s from " + sessionClass + " s " + "left outer join fetch s.sudoer " + "left outer join fetch s.annotationLinks l " + "left outer join fetch l.child a where s.id = :id", new Parameters().addId(id).cache()); }