• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Hibernate: multiple subclasses not using fetchmode join

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm having weird issues trying to use fetch="join" on the properties of more than one subclass of my hibernate mapping file.

First, the situation: I have a constellation of one-to-many tables related by foreign key to a single parent table. The parent table defines the superclass, then overlapping subsets of the related tables define the subclasses. So subclass A will have sets of type (X, Y, and Z) and subclass B will have sets of type (X, V, and W) .

The Hibernate Mapping file looks like this:

The Criteria query used looks like this:

Now, when I execute that Criteria (in order to get both As and Bs back), the select statement output joins V, W, X, Y, and Z (just like you'd think it would). Attempts to access a returned object of type A's properties are successful without Lazy loading (as I want it to be), but any attempt to access an object of type B's properties results in them being lazy loaded, even though they should be available.

But it gets weirder! Which subclass has immediate access to the SELECTed information is position dependent! If I swap subclass B above subclass A in the mapping file, then it works fine, while class A does the lazy loading.

I've also tried moving class A out to an external mapping file, but the behavior is the same, it still insists on lazy loading its properties.

If anybody has seen this before and has a solution, or even has a suggestion about what I should try next, I would be extremely grateful. It seems to me that any behavior that treats one sibling differently from another is not working as designed.

Thanks for your time,

And inside of my fortune cookie was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic