小编Оле*_*нюк的帖子

Spring Data @Query + 规范

你能帮我连接规范和查询吗?分页工作完美,但我对规范有问题,没有在其中添加搜索参数。

public interface RakebackRepository extends JpaRepository<Rakeback, Long>,JpaSpecificationExecutor<Rakeback> {

    @Override    
    @Query(value = "SELECT new domain.model.poker.rakeback.Rakeback(ppr.playerId, SUM(ppr.rakeSum), SUM(ppr.fullRakeBackSum), max(ppra.rakeBackBalance), max(ppra.rakebackRank)) FROM Rakeback as ppr LEFT JOIN ppr.Rakeback as ppra on ppra.status = 'active' LEFT JOIN ppra.rakebackRank as rbb on ppra.rakeBackRankId = rbb.id GROUP BY ppr.playerId ")   
    Page<Rakeback> findAll(Specification<Rakeback> specification, Pageable pageable);
    
    }
Run Code Online (Sandbox Code Playgroud)

这是来自日志的 SQL

select pokerplaye0_.player_id as col_0_0_,  sum(pokerplaye0_.rake_sum) as col_1_0_,  sum(pokerplaye0_.full_rake_back_sum) as col_2_0_,  max(pokerplaye1_.rake_back_balance) as col_3_0_,  max(pokerplaye1_.rake_back_rank_id) as col_4_0_ 
from rakeback.players_rakebacks pokerplaye0_  
left outer join rakeback.players_rakebacks pokerplaye1_ on pokerplaye0_.player_id=pokerplaye1_.player_id and (pokerplaye1_.status='active') …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate specifications jpa

2
推荐指数
1
解决办法
1364
查看次数

标签 统计

hibernate ×1

java ×1

jpa ×1

specifications ×1

spring ×1