sql - Select entity and ids of its surrounding entities - Stack Overflow

This is my queryIt is meant to return the selectedResponse and its next and previous ids. As you can s

This is my query It is meant to return the selectedResponse and its next and previous ids. As you can see, the Where clause currently constrains the results. I tried a nested select and CTE, both resulted in errors. In my previous implementation, I used nested selects with limit one, that resulted in n+1. I can't use joins, due to the issues with the parent ids (it was getting ids from another requests).

@Query("""
      SELECT
      new code.modules.conversation.data.jpa.projection.ResponseWindow(
        res,
        LAG(res.id) OVER (PARTITION BY res.request ORDER BY res.created),
        LEAD(res.id) OVER (PARTITION BY res.request ORDER BY res.created)
      )
      FROM ResponseEntity res
      WHERE res = :selectedResponse
    """)
    ```

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745596596a4635153.html

相关推荐

  • sql - Select entity and ids of its surrounding entities - Stack Overflow

    This is my queryIt is meant to return the selectedResponse and its next and previous ids. As you can s

    17小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信