Hi, everyone.
I need to develop an application which uses distributed data sources and synchronizes data between then. Each data source is unique identified by an integer number. All data sources contain similar data but data schemes could slightly differ. For example, there are two kinds of data sources: a newly developed application database and legacy database. I'm going to develop some kind of data adapter from legacy database data to new application database format.
Key requirements are: - each object must be uniquely identified within distributed system via database id and local object id - objects can migrate from one database to another in a tricky way
My question is related to an implementation of identification strategy.
Let's say we can't use UUIDs for object identification.
Alternative #1: Using composite identifiers Pros - a natural and simple solution - a simple way to implement data source-based analytics (if needed)
Cons - need to develop identifier generator which actually implemented in Hibernate (enhanced table generator) - need to manually assign identifier to the object - I need to consider two-column identifier in queries and mappings
Alternative #2: Using long identifiers. First two bytes of identifier are the database id Pros - I can implement identifier generator and tell Hibernate to use it (reuse existing code) - mappings and queries become simpler, because there's only one key field - don't need to manually assign identifiers to objects
Cons - there's an implication in identifier value - It becomes a bit harder to develop data source-based analytics (if needed)
I would like to know the community opinion about these alternatives. Are there other pros & cons of each? Am I missing something?
For now I've implemented the first alternative and I don't like it much.
|