@Filter query is not passed through the current dialect

Description

Hello,

I have the following entity:

When I use this entity with the filter enabled against Oracle database I get the following exception:

If I change the filter condition to be


then the Oracle works fine but I will probably break the MySQL clients.

I think is caused because the condition is not translated with the specified dialect (I have specified this dialect: "org.hibernate.dialect.Oracle12cDialect")

Environment

ubuntu linux, oracle 12c express edition.

Activity

Show:
Nayden Gochev
August 25, 2017, 9:16 AM
Edited

Thanks for the suggestion havent tried this yet, but it looks with JPA 2.1 Converter it actually works.
Tested on Postgres 9.5.4.2, MySQL 5.1 and Oracle 12.2 and it works.

Anyway it works like this:
The filter:

The column:

And the converter looks like this:

Yes in the database even on MySQL now everything is int.. but

Vlad Mihalcea
August 25, 2017, 9:35 AM

But that will work only if the DB column is an Integer, not a Boolean type. That means you can't use a Boolean DB type like you'd have in PostgreSQL, right?

Nayden Gochev
August 25, 2017, 9:41 AM

Yes currently the type is int in all databases, and never boolean, since Oracle doesn't have boolean so currently we dont have boolean anywhere.

We will try your solution as well, however I am thinking about a customer having an issue.... probably it will be easier for the support to explain customers/clients and tell them just "add this converter and use = 1", instead of change the filter to have parameter and pass the parameter before executing your query

Vlad Mihalcea
August 25, 2017, 9:46 AM

Or, you could use queries which are more flexible than Filter. In fact, an extensive usage of Filter can be a Code Smell as it might indicate that entities are fetched even when DTO projections would have been a way better choice for read-only views.

For more details, check out this article.

Petar Tahchiev
July 26, 2018, 3:10 PM

Any updates on this? Yes, extensive Filter usage can be dangerous, but this issue is not about that. Even if I use the Filter only once in my project it is blocking me as I'm basically writing database-specific SQL query and it is preventing me from achieving what Hibernarte claims to - database agnostic sql independence.

Assignee

Unassigned

Reporter

Petar Tahchiev

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure