This is a design question involving multiple Hibernate instances.
My distributed application has one server and n clients. The server and all clients have databases with the same schema. The idea is that objects are created/updated/deleted either at the server or at one of the clients, and from time to time, all databases synchronize so that everyone has the same content. I am not sure how to handle object IDs in such scenario.
My approach was to make both local and remote objects have always the same ID, so that updating the local object with its remote copy would be easy. For this to work, the ID would have to be created always at the server. However, in some cases the object must be first created locally, at a time the server is not available.
My second idea is to use UUIDs but I am unsure if this would slow down the application too much?
Does anyone have any thoughts on this, and does anyone know how to tackle this problem with distinct local and remote IDs?
Any help is greatly appreciated!
|