Hi,
My requirement is 'we should join two tables (where they don't have any associations) and retrieve the data by projecting only specific columns'.
I did the Column filtering using the Criteria.Projections functionality. And here, I want to introduce a join condition with one generic table which actually don't have any specific association with my target table.
Let me give my table structures and actual requirement,
Table1: Account (accoun_id, name, firm_id, firm_rep_id, etc..)
Table2: Firm (firm_id, name, etc...)
Table3: FirmRep (firm_rep_id, name, etc...)
Table4: List (list_id, name, member_type, etc...)
Table5: ListMember (list_member_id, list_id, entity_value, etc...)
Assume that, the first 3 tables are the master tables and the last 2 tables are generic list tables, to maintain the list of master data.
I would mean here that List & ListMember tables can contain Account list, Firm list and FirmRep list. And the type of the list can be identified by its member_type, whereas the ListMember table will contain the list of account_Ids / firm_ids / firm_rep_ids in the entity_value column.
So here, my requirement is
1. I need to retrieve the list of accounts by just supplying the list_id using join. (By projecting only specific fields)
2. I need to retrieve the list of firms by just supplying the list_id. (By projecting only specific fields)
3. I need to retrieve the list of firm reps by just supplying the list_id. (By projecting only specific fields)
4. All the above will be implemented in different methods. So retrieving need not to be very generic as like all the three will be implemented in only one method.
So here, you could observe that we can't provide an association mapping between the ListMember(entity_value) to any tables.
In these scenario, how can I write or create my Hibernate Criteria object to retrieve the list of accounts / firms / firmreps.
The question is how to add a join condition in a Criteria where the two tables don't have any association mappings.
Any help, would be highly appreciated.
_________________ Thanks
Thiruppathy.R
|