I’m need to make a query that retrieves me the values for an Ltree stored in my Postgres database.
The tools I’m using is Kotlin, Quarkus and Hibernate Panache.
I succeed retrieving this data using raw queries like this:
entityManager.createNativeQuery(
"SELECT * FROM MY_TABLE WHERE path @> CAST(:ltreeValue AS ltree) AND path !=
CAST(:ltreeValue AS ltree)"
)
after that I decided to also try with raw named query:
@NamedNativeQuery(
query = "SELECT * FROM MY_TABLE WHERE path @> CAST(:ltreeValue AS ltree) AND path != CAST(:ltreeValue AS ltree)",
name = "findPath"
)
So both approaches worked.
But what I need is to avoid writing raw queries, it doesn’t matter which one of the previous approaches (either directly in the code or annotation) and instead use Hibernate Criteria or Hibernate HQL.
My biggest problem with Hibernate Criteria and Hibernate HQL is I couldn’t make it understand the “@>” operator.
Any thoughts on that please?