Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
2.0:
I have an entity (Person) which contains a collection of a component type (Address). I have defined the following mapping.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >
<class name="ABC.Person, ABC" table="person">
<id name="Id" type="guid" column="person_id">
<generator class="guid" />
</id>
<version name="Version" column="version" />
<property name="Name" />
<bag name="Addresses" table="person_addresses" lazy="true">
<key column="person_id" foreign-key="FK_Address_Person" />
<composite-element class="ABC.Address, ABC">
<property name="value" not-null="true"/>
</composite-element>
</bag>
</class>
</hibernate-mapping>
I want to define a unique constraint on component type such that the combination of "person_id" and "value" column should be unique. Altough "Property" tag has a "unique-key" attribute available but "key" tag doesn't allow anything like that.
One way to enforce uniqueness would be to use a set but that wouldn't create the Unique constraint in database and I am using hbm2ddl to generate the schema.
Help is much appreciated.
Cheers
Syed.