RobJellinghaus wrote:
(I honestly have no idea what Hibernate does if you try to reset the Java identifier for an object -- I've *never* done it in our system. What would you want it to do in this case? Delete the current Instance row and insert a new one?)
(Duh, forgot to quote and reply to this part). Well, what you asked above is the whole problem about assigned identifiers. What you should do if the user changes the identifier? The current web interface for the classes described above behaves like this:
1) Believes what the user said, so if he's asking to create a new domain with the code MYDOMAIN, issue an INSERT database. If we get a primary key violation, there's already a domain with such code. Inform this to the user and ask him to pick another code.
2) If the user is asking to update the domain MYDOMAIN, issue an UPDATE for it. If no rows are affected, the domain don't actually exists. Inform this to the user, and asks if he wants to create a new domain.
3) If the user is asking to delete the domain MYDOMAIN, issue a DELETE for it. If no rows are affected, inform this to the user and say you're sorry.
Please note that on (2) and (3) the user don't actually type the domain code -- it's usually selected from a list. So, if the user asked to update or delete a non-existent domain it's because another user removed it while the current user was looking at the list (and that's exactly what the current interface tells to the user when this happens).