Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPQL query for all entities in descending order returns no results on Oracle #2336

Closed
anija-anil opened this issue Dec 23, 2024 · 0 comments
Closed

Comments

@anija-anil
Copy link
Contributor

A Jakarta Data test fails with,

java.util.NoSuchElementException: No value present at java.base/java.util.Optional.orElseThrow(Optional.java:377) at test.jakarta.data.web.DataTestServlet.testFindAndDeleteReturnsIds(DataTestServlet.java:1822)

After persisting a number of entities, Jakarta Data sent the following JPQL:

SELECT ID FROM Package ORDER BY WIDTH DESC

EclipseLink turned this into a SQL query that didn't produce any results:

[12/19/24, 13:27:49:861 CST] 00000039 id=00000000 eclipselink.ps.query                                         3 Execute query ReportQuery(referenceClass=Package sql="SELECT ID FROM Package ORDER BY WIDTH DESC")
[12/19/24, 13:27:49:861 CST] 00000039 id=00000000 eclipselink.ps.transaction                                   3 TX beginTransaction, status=STATUS_ACTIVE
[12/19/24, 13:27:49:861 CST] 00000039 id=00000000 eclipselink.ps.connection                                    3 Connection acquired from connection pool [default].
[12/19/24, 13:27:49:861 CST] 00000039 id=00000000 eclipselink.ps.connection                                    3 reconnecting to external connection pool
[12/19/24, 13:27:49:954 CST] 00000039 id=00000000 eclipselink.ps.sql                                           3 SELECT ID AS a1 FROM Package WHERE (ID) IN (SELECT null FROM (SELECT null, ROWNUM rnum  FROM (SELECT ID AS a1 FROM Package ORDER BY WIDTH DESC) WHERE ROWNUM <= ?) WHERE rnum > ? )  ORDER BY WIDTH DESC FOR UPDATE
	bind => [2 parameters bound]

Also, a second Jakarta Data test fails similarly,

java.util.NoSuchElementException: No value present
at java.base/java.util.Optional.orElseThrow(Optional.java:377)
at test.jakarta.data.web.DataTestServlet.testFindAndDeleteReturnsIds(DataTestServlet.java:1822) 

In this test, Jakarta Data persists entities and then sends the following JPQL:

SELECT NEW test.jakarta.data.jpa.web.CityId(o.name, o.stateName) FROM City o WHERE (o.stateName=?1) ORDER BY o.name

EclipseLink turns this into a SQL query and finds no results:

[12/19/24, 13:18:58:006 CST] 0000003a id=00000000 eclipselink.ps.query                                         3 Execute query ReportQuery(referenceClass=City sql="SELECT NAME, STATENAME FROM City WHERE (STATENAME = ?) ORDER BY NAME")
[12/19/24, 13:18:58:006 CST] 0000003a id=00000000 eclipselink.ps.transaction                                   3 TX beginTransaction, status=STATUS_ACTIVE
[12/19/24, 13:18:58:006 CST] 0000003a id=00000000 eclipselink.ps.connection                                    3 Connection acquired from connection pool [default].
[12/19/24, 13:18:58:006 CST] 0000003a id=00000000 eclipselink.ps.connection                                    3 reconnecting to external connection pool
[12/19/24, 13:18:58:082 CST] 0000003a id=00000000 eclipselink.ps.sql                                           3 SELECT NAME AS a1, STATENAME AS a2 FROM City WHERE (STATENAME = ?) AND (STATENAME,NAME) IN (SELECT null,null FROM (SELECT null,null, ROWNUM rnum  FROM (SELECT NAME AS a1, STATENAME AS a2 FROM City WHERE (STATENAME = ?) ORDER BY NAME) WHERE ROWNUM <= ?) WHERE rnum > ? )  ORDER BY NAME FOR UPDATE
	bind => [4 parameters bound]

It should be noted that the City entity has an @IdClass(CityId.class) where CityId has String fields: name, stateName corresponding to fields of the City entity:

    @Id
    public String name;

    @Id
    public String stateName;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant