Forums Register Login

How to implement this contraint at the mapping file level ?

+Pie Number of slices to send: Send
Hi.
My domain objects has a Category object.
This Category object has two relationshipts : parentCategory and childCategories (actually, I'm using CeveatEmptor Category class).
But there is a requirment, no two categories have the same name at the same level (same level here means the same categetory parent).
Well, CeveatEmptor Category.hbm.xml has the following :

I tried the following :
insert into category values (1, 0, "Computer", null);
insert into category values (2, 0, "Software", 1);
insert into category values (3, 0, "Porgramming", 2);
insert into category values (4, 0, "Databases", 2);
Here, at the forth line I got an exception about breaking FK contraint.
Any help how to implement my requirement (at the mapping level if possible) ? (I'm not SQL guru)
BTW, what unique-key attribute means ?
Thanks.
Climb the rope! CLIMB THE ROPE! You too tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 887 times.
Similar Threads
Need many-to-one mapping help
1-to-M mapping confusion
Hibernate self referential interigity
one-to-many relation
Hibernate Cascade
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 22:54:00.