pasha wrote:
you could map your discriminator column to a no insert/no update property, and then easily use it in your HQL or Criteria...
We found something similar, which was to map each of the subtypes that the discriminator chooses against to a getter method and the cfg.hbm document, and then we're able to select that class directly by using a restriction on the parent class.
If the parent abstract class is Foo, and Foo has a T getValue() method, then the discriminator maps to subclasses of Foo. We added getFooDouble() getFooString(), etc to the parent class, then we can use any of those in the Criteria query.
I was hoping to have some 'smarter' way to query out what I wanted, but hibernate isn't smart enough to look at whatever value I pass into the query and determine the subtype of Foo.
It's too bad you can't join Criteria Queries together more easily, or I could specifically start a criteria query against the subtype I wanted, and do an association to the main query.