Hi Sachin,
I know it's quite late to reply, and maybe you found a solution yet.
I'm facing the same problem: how to create unique indexes on multiple columns in mapping files.
I found the tag "properties" and applied my usual learn-by-doing approach. Actually it does what you think: create a [unique] index on the columns listed inside.
So, I went on with my project but there is a problem: Hibernate goes mad with aliases if they refer to the child properties of the tag "properties".
To explain, this is the mapping example I made (a simple localization labels storage):
Code:
<class name="it.innove.multilanguage.entities.LabelText" table="innove_label_texts">
<id name="id" column="id">
<generator class="guid" />
</id>
<properties name="lnl" unique="true">
<many-to-one name="language" column="language"
class="it.innove.multilanguage.entities.Language" fetch="select" lazy="false" />
<many-to-one name="label" column="label"
class="it.innove.multilanguage.entities.Label" fetch="select" lazy="false" />
<properties>
<property name="text" type="string">
<column name="text" sql-type="TEXT" />
</property>
</class>
but when I try to fetch LabelText objects I get an "Unknown column: alias_0x1_.language" error.
Is there anybody who has another solution?
Thanks,
Stefano