0

I'd like to do the following in HQL: join the main truncated table only if corresponding entry is found - IF NOT FOUND - join with table's backup (which contains the rest of the data) Something like:

select a TranxtionAuthorization left join fetch a.tranxtion *left join fetch mybackupTable IF main join entries are NULL*

Now two issues:

  1. coalesce is not an option since I am not fetching individual fields
  2. and mainly my myBackupTable is not mapped in TranxtionAuthorization xml file (only the main table is <=> 1st join). So I cannot build the second join anyway

I would like to know what options if this is possible and if so - what are my options.

Best answers I've found so far would be to reference the two tables in Tranxtion xml file (which itself is referenced to in TranxtionAuthorization). Details here: Map Two Identical tables ( same schema...) to same entity in Hibernate. It seems like that could help figure out Issue #2 liste above. In that case does it mean that I would not need the second join. And would actually fetch the first non null entry mapped from either main table or the backup?

Not sure. Any input/guidance is appreciated.

Thanks in advance

Alassane
  • 21
  • 7

0 Answers0