hi, can anybody tell me whether we can use discriminator on two columns.....in hibernate that means i want to fetch data basing on two columns [ October 29, 2008: Message edited by: jani basha ]
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.
indeed. i was missing the formula attribute. sry for that. my bad. however, i'm still not sure why you would need such a complicated method for such a basic task.
jani basha
Greenhorn
Joined: Oct 23, 2008
Posts: 8
posted
0
thanks for your replies....
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...."
If "fax out" is part of your discriminator you can't use it as Criteria because, as mentioned above, discriminators are hidden from your application.
You can select all of the types you've defined to be identified by this discriminator though.
This all sounds a little suspect - isn't this just the state of one type rather than multiple types? Multi-value discriminators are (I'd imagine) very unusual things.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.