public static List < Dashboard > findDashboards ( EntityManager em , Integer limit , String version ) { requireArgument ( em != null , "Entity manager can not be null." ) ; TypedQuery < Dashboard > query ; if ( version == null ) { query = em . createNamedQuery ( "Dashboard.getDashboards" , Dashboard . class ) ; } else { query = em . createNamedQuery ( "Dashboard.getDashboardsByVersion" , Dashboard . class ) ; query . setParameter ( "version" , version ) ; } try { if ( limit != null ) { query . setMaxResults ( limit ) ; } return query . getResultList ( ) ; } catch ( NoResultException ex ) { return new ArrayList <> ( 0 ) ; } }
Returns dashboards ordered by owner and dashboard name .