• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: multiple subclasses not using fetchmode join

 
Matt LeVan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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,

matt
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic