@Override
    public ResourceSet save(final ResourceSet set) {
        if (!validateResourceSetScopes(set)) {
            throw new IllegalArgumentException("Cannot save a resource set with inconsistent scopes.");
        }
        val jpaResource = new JpaResourceSet();
        FunctionUtils.doUnchecked(__ -> BeanUtils.copyProperties(jpaResource, set));

        val isNew = jpaResource.getId() <= 0;
        val r = this.entityManager.merge(jpaResource);
        if (!isNew) {
            this.entityManager.persist(r);
        }
        return r;
    }
This is {@link JpaResourceSetRepository}.

@author Misagh Moayyed
@since 6.0.0
support/cas-server-support-oauth-uma-jpa/src/main/java/org/apereo/cas/uma/ticket/resource/repository/impl/JpaResourceSetRepository.java