public TokenSyncDate getTokenSyncDate ( Integer subscriptionId ) { EntityManager entityManager = getEntityManager ( ) ; try { List < TokenSyncDate > list = entityManager . createQuery ( "SELECT syncDate FROM TokenSyncDate AS syncDate WHERE subscriptionId = :subscriptionId" , TokenSyncDate . class ) . setMaxResults ( 1 ) . setParameter ( "subscriptionId" , subscriptionId ) . getResultList ( ) ; if ( ! list . isEmpty ( ) ) { return list . get ( 0 ) ; } return null ; } finally { entityManager . close ( ) ; } }
get the date the tokens where last synced for the subscriptionId passed as argument