@Query("SELECT r.id from Role r where (r.roleName = CONCAT('Master+', ?1) " + "OR r.roleName like CONCAT('ModifyNamespace+', ?1, '+%') " + "OR r.roleName like CONCAT('ReleaseNamespace+', ?1, '+%'))") List<Long> findRoleIdsByAppId(String appId);
@Query("SELECT r.id from Role r where (r.roleName = CONCAT('ModifyNamespace+', ?1, '+', ?2) " + "OR r.roleName = CONCAT('ReleaseNamespace+', ?1, '+', ?2))") List<Long> findRoleIdsByAppIdAndNamespace(String appId, String namespaceName);
@Query("SELECT p.id from Permission p where p.targetId = ?1 or p.targetId like CONCAT(?1, '+%')") List<Long> findPermissionIdsByAppId(String appId);
@Query("SELECT p.id from Permission p where p.targetId = CONCAT(?1, '+', ?2)") List<Long> findPermissionIdsByAppIdAndNamespace(String appId, String namespaceName);
@Query( value = "select b.Id from `InstanceConfig` a inner join `Instance` b on b.Id =" + " a.`InstanceId` where a.`ConfigAppId` = :configAppId and a.`ConfigClusterName` = " + ":clusterName and a.`ConfigNamespaceName` = :namespaceName and a.`DataChange_LastTime` " + "> :validDate and b.`AppId` = :instanceAppId", countQuery = "select count(1) from `InstanceConfig` a inner join `Instance` b on b.id =" + " a.`InstanceId` where a.`ConfigAppId` = :configAppId and a.`ConfigClusterName` = " + ":clusterName and a.`ConfigNamespaceName` = :namespaceName and a.`DataChange_LastTime` " + "> :validDate and b.`AppId` = :instanceAppId", nativeQuery = true) Page<Object> findInstanceIdsByNamespaceAndInstanceAppId( @Param("instanceAppId") String instanceAppId, @Param("configAppId") String configAppId, @Param("clusterName") String clusterName, @Param("namespaceName") String namespaceName, @Param("validDate") Date validDate, Pageable pageable); }
/** * Sample method to demonstrate support for {@link Stream} as a return type with a custom query. The query is executed * in a streaming fashion which means that the method returns as soon as the first results are ready. * * @return */ @Query("select c from Customer c") Stream<Customer> streamAllCustomers();
/** * A DTO projection using a constructor expression in a manually declared query. * * @param firstname * @return */ @Query("select new example.springdata.jpa.projections.CustomerDto(c.firstname) from Customer c where c.firstname = ?1") Collection<CustomerDto> findDtoWithConstructorExpression(String firstname);