Normally, a discriminator will just be an arbitrary value since the state of an entity would not normally also change its type (and discriminators are never exposed to the application). Have you really got entities that need to behave this way? Your example look (to my uninformed eye) like state for one object type, not different types.
I think you could do it with a formula, since the hibernate-mapping dtd allows either a column or a fomula in a discriminator. You would need to come up with some formula based on these field values that returns an evaluable value.
You could also investigate the Hibernate <any /> mapping. This gives a mechanism to map polymorphic associations based on more than one field.
I don't think you can have a discriminator on two columns. I say this based on the validation schema for the mapping xml.
Discriminators are used only to distinguish between 2 child classes (or implementations of the same interface) when you map a class hierarchy, so I can't think of any situation in which you would need 2 columns to fulfill such a basic function.
Maybe you should recheck if what you need in your situation is a discriminator.
yes we may achieve this by using formula attribute. but while fetching the data if i want to retrieve only the records which are of status "fax out". In this scenario where i have to use criteria as fallows
Criteria criteria = session.createCriteria(data.class,"fax"); by using this i may not get the required result.
it will be fine if i can pass one more param as "out" that means if discrmininator="col1,col2,col3...."