Apologies if this is re post. I have three classes A, B(subclass of A), and C.
B has a Set of elements of C.
In the database there are three corresponding tables A_TABLE, B_TABLE, and C_TABLE, and an additional view B_VIEW which is what B is mapped to(instead of B_TABLE, because the view has data from additional tables). On inserts into B_VIEW, a trigger in the database inserts a row into B_TABLE using a sequence. The code and mapping for A&B has existed before as did all the database tables and views. I am trying to add a set mapping for C.
While the data is inserted into C_TABLE correctly (due to B lacking an Id, there is an insert of B only followed by update of B with the set of C attached ), the issue is that on the read path (load collections from database), hibernate does not load anything because in the criteria query it tries to use the value of aId (instead of value of bId) in the query, even though the column name is correct. The issue arises because B is mapped using a <join> without an entity id, and hibernate has all the B instances at runtime identified with aId.
My Question is whether there is a way to fix this, perhaps by telling hibernate that it should use bId as the foreign key instead of aId during the load. I know this is twisted, but the code has existed for a long time. TIA for any suggestions and help.