@Override
    public long count(final String username) {
        val count = (Number) entityManager.createQuery(
                "SELECT COUNT(r.username) FROM " + ENTITY_NAME + " r WHERE r.username=:username")
            .setParameter("username", username.toLowerCase(Locale.ENGLISH).trim())
            .getSingleResult();
        LOGGER.debug("Counted [{}] record(s) for [{}]", count, username);
        return count.longValue();
    }
This is {@link JpaGoogleAuthenticatorTokenCredentialRepository} that stores gauth data into a RDBMS database.

@author Misagh Moayyed
@since 5.0.0
support/cas-server-support-gauth-jpa/src/main/java/org/apereo/cas/gauth/credential/JpaGoogleAuthenticatorTokenCredentialRepository.java