Hi all,
is there a way to associate custom SQL to an object column while saving? What I want is this?
I have a class with a composite key being:
- parentId
- sequence
the sequence should be generated upon insertion and for each parentId, using something like "COALESCE(MAX(sequence), 0) + 1" (this is the easiest way). The other choice is to get that number, associate it to the composite id, and then save the object. But this approach is too troublesome, as it means having to do a select first, and only afterwards being able to persist the object...
Any ideas?
Thank you.
|