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")
ubuntu linux, oracle 12c express edition.
Thanks for the suggestion havent tried this yet, but it looks with JPA 2.1 Converter it actually works.
Tested on Postgres 126.96.36.199, MySQL 5.1 and Oracle 12.2 and it works.
Anyway it works like this:
And the converter looks like this:
Yes in the database even on MySQL now everything is int.. but
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?
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
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.
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.