Blazebit / blaze-persistence

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

Is there any way to use @Limit dynamically #1941

Open shopera007 opened 1 day ago

shopera007 commented 1 day 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 12 hours 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)