• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown

Parent class id value instead of child's id used incorrectly for querying Set assoc.

Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Query at runtime:

Java classes:

Hibernate Mappings



Let me tell you a story about a man named Jed. He made this tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic