Search code examples
springhibernatejpamariadbquerydsl

Querydsl delete query using limit


I have a one question.

I want to use limit for delete query with querydsl. Is there any way?

delete(wedul).where(wedul.id.eq(10)).limit(10)

Solution

  • JPA (on which hibernate and querydsl is built) does not support something like a limit or rownum for deletes, because it is not a universally supported database concept.

    A common approach to solving this would be to delete from the table where the 'id' in contained within a subquery, and the place the limits on the subquery.

    See this other answer