I have an abstract class with two subclasses and I’m using the inheritance strategy ‘table_per_class’.
The class One has some fields that class Two has not, when I need to execute a search, hibernate creates a union select and it adds a ‘null cast’ for these missing fields in the select of table Two, here is the problem:
Before migrate, it used null::varchar for cast missing String fields, and after migrate (now I’m in hibernate 6.6) it is using cast(null as text).
The fact of use text instead of varchar is making Postgres executes seq scan instead index scan.
Is there a way to tell hibernate to use varchar is this scenario?
That’s weird, text
is just the same type as archer
without the size limit. I don’t see why that would prevent an index from being used. Have you tried reaching out to the Postgres folks about this?
I’m afraid not, no.
I think this was fixed with this Jira. Can you please upgrade to ORM 7.0 and confirm this fixes the problem for you? Then we can consider backporting it.
What good news, I’ll check and return as soon as possible!!