SAP / olingo-jpa-processor-v4

The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.
Apache License 2.0
127 stars 79 forks source link

Complex filter is creating more brackets than it should #59

Closed chentopf closed 11 months ago

chentopf commented 6 years ago

Hi If i am calling /Projects?$filter = Id eq 33 or Id eq 34 The query generated looks like: select from projects where ((Id = 33) or (id =34)) In a very complex query with many 'OR' this could cause problem. The correct query should be something like this: select from projects where (Id = 33 or id =34)

wog48 commented 6 years ago

Hello,

the additional brackets around the single comparisons, Id = 33, are not generated by the JPA Processor, but by the JPA implementation itself, so EclipseLink or Hibernate.

I saw that behavior by different tools/frameworks generating SQL. To be honest I never investigated why they are doing so. I assume that a generation of brackets around everything is a simple way to ensure that the sequence method calls (so here the calls of the criteria builder methods) are converted correctly into SQL, especially in case the WHERE clause becomes more complex.

wog48 commented 11 months ago

Due to clean-up action. All issues created before 2022 get closed.