I'm wondering if anyone has any recommendations on how to deal with database constraints, especially in regard to List mappings.
Here's my situation:
* I have a parent-child relationship. The child is collection is ordered.
* The database has unique two-column index on the parent_id and seq_no fields in the child table.
* Whenever I am forced to reorder (e.g. by removing the first child element), Hibernate of course is not able to know the order in which to perform the updates, and triggers a constraint violation.
I am able to work around this by manually mucking with the SeqNo of each child element, flushing, then reordering and flushing again, but it's not terribly satisfying. I'm hoping there's a more elegant way.
I've considered writing an Interceptor to scan for this condition, but I don't think I can do it transactionally using this approach.
Does anyone have any suggestions? Perhaps there's some Hibernate feature I've overlooked?
Thanks in advance!
|