I've searched both this forum and google for a long time today, and I just have no clue how to solve my problem.
The problem is, we've got an application where we have no control over the database structure. It is what it is.
I have one table (let's call it DET) with a column for diagnostic type (DIG). That DIG code is tied to a reference table (let's call it DIG_CDS).
So, in the DET.DIG column, we can have a value such as '7330' (Yes, it's a string). However, in our reference code table, DIG_CDS, we've got multiple rows identified by DIG. the DIG_CDS table has additional columns for Version and effective start/end dates. Basically, I need to find the highest version number where the start/end dates surround another date on a parent table to DET.
I've tried mapping subselects, filters, functions, and nothing gets me to where I need it.
Is there anything I can do with interceptors or event listeners before or during the load to manipulate the query?
When I try to load the DET object it is fine, but once I try to lazy load the diagnosis code:
Code:
detRecord.getDiagnosisType()
I get the expected error of:
Code:
The exception is: More than one row with the given identifier was found: 7330, for class: xxx.det.DiagnosisType.
I realize this database design isn't proper, but we cannot change the db structure. Is there anything we can do to load the DiagnosisType? I can load lists of Diagnosis Types, and I can even save Diagnosis types with values that are either unique or duplicated in the reference table. It's just loading an individual value for on-screen display is dying.
Thanks