I am wondering if there is any neater way to do the following.
s = (Session) em.createQuery( "SELECT DISTINCT s " + "FROM Session as s " + "WHERE s.sessionId = :sessionId") .setParameter("sessionId", sessionId) .getSingleResult(); for(SessionSupplier sessionSupplier:s.getSessionSuppliers()) { sessionSupplier.getSessionSupplierLocations().size(); }
s = (Session) em.createQuery( "SELECT DISTINCT s " + "FROM Session as s " + "LEFT JOIN FETCH s.sessionSuppliers as ss " + "LEFT JOIN FETCH ss.sessionSupplierLocations as ssl " + "WHERE s.sessionId = :sessionId") .setParameter("sessionId", sessionId) .getSingleResult();