I'm trying to programitically figure out the discriminator value if I have a class. Is there a recommended way to find the value? There doesn't seem to be a method on ClassMetadata like discriminatorValue().
For a generic reporting funtion, I'm trying to create a criteria that restricts itself to a sub-class of records for a joined property. For example:
Code:
public List void findRecords(Class restrictToClass){
Criteria c = session.createCriteria(Primary.class);
Criteria cProperty = c.createCritiera("joinProperty");
cProperty.add(Expression.eq("class", restrictToClass));
return c.list();
}
However, the discriminator value must be used and not the class name.
If it doesn't exist, I'm looking to write the translation method (class->value). I started down the path of subclassing EqExpression and changing getTypeValue (to do the translation since it has access to PresistorClass where the value is available) and I was wondering if there is a better way to accomplish this.
I can always hard code the discriminator value; however, I'm trying to make the code easier to read and maintain.....
Chris....