I need to write a custom criterion to check for inheritance. My desire is to use it like this:
Code:
Criteria getDomesticCars = session.createCriteria( Car.class )
.add( new ExtendsCriteria( "manufacturer", DomesticManufacturer.class ) )
.list( );
Basically, what I need to do is:
1. Determine the inheritance strategy (table-per-subclass, discriminator, or mixed)
2. Get the discriminator column if present
3. Get the discriminator values and/or joined tables involved
4. Identify the discriminator values represent the specified class or any of its subclasses (as defined in the mapping)
5. Construct a SQL query string (where discriminator in (x, y, z, ...) or where id in (select id from joined_table))
I'm having some trouble with 1-3. I've looked through the API documentation at CriteriaQuery, SessionFactoryImplementor, and EntityPersister and I haven't seen any methods resembling hasDiscriminator( ) or getDiscriminator( ) or getJoinedTable( ). Am I looking in the right place? If not, where should I be looking? Also, are custom Criterion implementations future-proof, or are they tied to implementions (vice interfaces)?
Thanks in advance,
- Jesse