Spring security 具有安全评估ContextensionSupport的Spring数据JPA不工作

Spring security 具有安全评估ContextensionSupport的Spring数据JPA不工作,spring-security,spring-data,spring-data-jpa,spring-el,Spring Security,Spring Data,Spring Data Jpa,Spring El,我想使用SpringDataJPA的安全扩展支持来检查用户的权限,并相应地获取一些值。我正试图按照指示做这件事 下面是我的代码片段 @RepositoryRestResource(collectionResourceRel = "ProductStatus", path = "ProductStatus") public interface IProductStatusRepository extends CrudRepository<ProductStatusEntity

我想使用SpringDataJPA的安全扩展支持来检查用户的权限,并相应地获取一些值。我正试图按照指示做这件事

下面是我的代码片段

    @RepositoryRestResource(collectionResourceRel = "ProductStatus", path = "ProductStatus")
    public interface IProductStatusRepository extends CrudRepository<ProductStatusEntity, String> {
        @Query("SELECT p FROM ProductStatusEntity " +
                "?#{hasAuthority('ITManager') ? ' ' : ' WHERE ProductStatusCode NOT IN (\'VAL1\',\'VAL2\',\'VAL3\')'}")
        List<ProductStatusEntity> findStatusesByAuthority();
    }
我尝试了几个选项来处理?,:,hasprole,hassauthority等等。似乎什么都不起作用


对此有什么想法吗?

经过多次尝试和错误后,这一个成功了

@Query("select p from ProductStatusEntity p where p.productStatusCode NOT IN ( ?#{hasAuthority('ITManager') ? ' ' : @settings.productStatusExceptions})")
List<ProductStatusEntity> findStatusesByAuthority();
问题似乎是,只有在指定WHERE子句时,才能识别SpEL。。也许这可以改进。。不确定

@Query("select p from ProductStatusEntity p where p.productStatusCode NOT IN ( ?#{hasAuthority('ITManager') ? ' ' : @settings.productStatusExceptions})")
List<ProductStatusEntity> findStatusesByAuthority();