Blazebit / blaze-persistence

Rich Criteria API for JPA providers
https://persistence.blazebit.com
Apache License 2.0
742 stars 90 forks source link

Is there any way to use @Limit dynamically #1941

Closed shopera007 closed 1 month ago

shopera007 commented 1 month ago

Hello, How can I set a dynamic limit using the @Limit annotation in Blaze-Persistence when retrieving for example top-ranked answers for product questions in an entity view:

Here i want 5 to be dynamic like passing it when constructing the query

   @Limit(limit = "5", order = {"helpfulCount desc"})
        List<ProductAnswerView> answers,

Could you please help me out ?

beikov commented 1 month ago

Hi, you can use a parameter in the string e.g. @Limit(limit = ":answerLimit", order = {"helpfulCount desc"}) and bind that parameter on EntityViewSetting with addOptionalParameter("answerLimit", 5)