Access Indexed Items in JPQL

Is it possible to make access to indexed elements in JPQL, for example, in HQL :

select o from Order o where o.items[0].id = 1234

I could not find something related in JPA 2 specifications,

I am targeting the EclipseLink JPA here, so if you come up with an EclipseLink solution, that's fine, although a standard JPQL solution is preferred.

+3
source share
2 answers

The INDEX function should do the trick (I actually tested it):

SELECT o
FROM Order o JOIN o.items i
WHERE i.id = 1234
AND INDEX(i) = 0

From the JPA 2.0 specification ( 4.6.17.2.2 Arithmetic functions ):

INDEX , . INDEX , , .

+4

@Pascal Thivent . INDEX(), @OrderedColumn .

, Hibernate, INDEX() , , @OrderedColumn mappedBy : JPA 2.0 @OrderColumn Hibernate 3.5

0

Source: https://habr.com/ru/post/1747438/


All Articles