问题
There is an old database which needs to be ported to a new one but the porting process will take significant time during which the old db will remain operational. In the old DB the IDs are sequential numbers in the new one we need globally unique identifiers which in case of hibernate we are (or were) going to generate using the hibernate's built in UUID generation. I have no idea about how it(hibernate's UUID) works and don't know if this is the same as the java's native UUID generation. Actually hibernate provides 2 uuid generation strategies (uuid and uuid2).
The problem is that if we use hibernates generation it's possible that there will be a collision between the hibernate generated IDs and the IDs coming from the old DB while it's still working. We are going to write a number of oracle procedures to help us "smartly" transfer the IDs from the old database to the new one but what ID generation technique we should use in those procedures so we don't have ID collisions with the IDs generated by hibernate?
We can use oracle's built in GUID generator or write a procedure in java and use java's native UUID generator. But nowhere it's written that those 2 won't produce collisions with hibernate generated IDs.
来源:https://stackoverflow.com/questions/7918233/generating-ids-in-oracle-with-hibernate-backed-orm