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

SQL generated by odata-jpa-processor-cb is incompatible with Hibernate for scenarios where parameter ordinal order is not maintained. #359

Open
dbhandari555 opened this issue Aug 22, 2024 · 0 comments
Labels

Comments

@dbhandari555
Copy link
Contributor

dbhandari555 commented Aug 22, 2024

odata-jpa version used: 2.1.3 along with dependency on odata-jpa-processor-cb

Problem statement: We want to support pagination on expanded entities and for that we use the library provided odata-jpa-processor-cb extension. The SQL generated by the criteria builder has incompatibility issues with Hibernate because the criteria builder doesn't guarantee sequential parameter ordinals without gaps.

Let's take an example to demonstrate this
Given odata query : ("Organizations('1')?$expand=SupportEngineers($top=5)"))

The SQL native queries generated are attached in the file
queries generated for example odata.txt

The query of interest is the last one from the file that's referenced below:

SELECT DISTINCT E0."ID" S0, E1."Text" S1 FROM "OLINGO"."BusinessPartner" E0 INNER JOIN "OLINGO"."Comment" E1 ON (E0."ID" = E1."BusinessPartnerID") WHERE ((E0."ID" = ?5) AND (E0."Type" = ?6)) ORDER BY E0."ID" ASC

The above just has ordinal 5 and ordinal 6 as parameters(sno 1, 2, 3, 4 as they are not required for this query) and this is allowed in Eclipselink. Unfortunately the same kind of query when run on Hibernate results in "org.hibernate.QueryException: Gap in ordinal parameter positions; skipped 4" because Hibernate expects the ordinals to start from 1 and go incrementally up without any gaps for every SQL query.

@wog48 Since the only way to support pagination on expanded entities currently is through odata-jpa-processor-cb dependency and because this would affect major chunk of scenarios when the library dependency is used with Hibernate, is it possible to provide a fix?

@wog48 wog48 added the analysis label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants