Validate Composite unique key using Hibernate
Friends,
Can any one help on "How to validate a composite unique key" with hibernate.
Lets say table "MyTable" has columns
ID
Amount
ParentID
Type
Here ParentID & Type are composite unique. How do I enforce this rule via hibernate? OR is there any work around. Please help.
Thanks
[340 byte] By [
ILANGOa] at [2007-11-27 9:09:07]

# 2
Well the gurus haven't tured out as this is not a relevant forum.
However,let me take that query.
Well as far as i see there is no proper recommended solution for this problem however there is a concept of <composite-id>
eg:
<composite-id name="id" class="OrderLineId">
<key-property name="lineId"/>
<key-property name="orderId"/>
<key-property name="customerId"/>
</composite-id>
NOTE: There is an alternative <composite-id> declaration to allow access to legacy data with composite keys. We strongly discourage its use for anything else.
REF:http://www.hibernate.org/hib_docs/reference/en/html/mapping.html
However follow the below link to get a better understading on it.
http://www.theserverside.com/discussions/thread.tss?thread_id=22638
http://www.hibernate.org/hib_docs/reference/en/html/components.html
http://www.xylax.net/hibernate/compositeid.html
however it would be gr8 if you post the similar query @ http://forums.hibernate.org.To get a better experts opnion.
Hope this might help if it does don't forget to duke stars which you promised :)
REGARDS,
RaHuL