Union in JPA query - from the same table

前端 未结 2 1492
渐次进展
渐次进展 2021-01-19 17:51

I have a requirement where I need to restrict number of records returned from a table for a particular flag and all records for the other flag value.

For example:

2条回答
  •  滥情空心
    2021-01-19 18:07

    JPA does not support UNION, but if you use EclipseLink, UNION is supported in JPQL. Also the COLUMN operator can be used to access special columns like rownum.

    See, http://java-persistence-performance.blogspot.com/2012/05/jpql-vs-sql-have-both-with-eclipselink.html

提交回复
热议问题