database - Using DTO Pattern to synchronize two schemas? -
i need synchronize 2 databases. databases stores same semantic objects physically different across 2 databases.
i plan use dto pattern uniformize object representation :
db ----> dto ----> mapping (getters / setters) ----> dto ----> db
i think it's better idea physically synchronize using sql query on each side, use hibernate add abstraction, , synchronize object.
do think, it's idea ?
doing orm might slower order of magnitude well-crafted sql script. depends on size of db.
edit
i add decision should depend on amount of differences between 2 schemas, not expertise sql. sql common developers should able write simple script in clean way.
sql has advantage know how run script, not know how run custom tool (this problem encountered in practice if migration operated else).
for schemas slightly differ (e.g. names, or simple transformation of column values), go sql script. more compact , straightforward use , communicate.
for schemas major differences, data organized in different tables or complex logic map value 1 schema other, dedicated tool may make sense. chances the initial effort write tool more important, can asset once created.
you should consider non-functional aspects, such exception handling, logging of errors, splitting work in smaller transaction (because there many data), etc.
sql script can indeed become "messy" under such conditions. if have such constraints, sql require advanced skills , tend hard use , maintain.
the custom tool can evolve mini-etl ability chunck work in small transactions, manage , log errors nicely, etc. more work, , can result in being dedicated project.
the decision yours.
Comments
Post a Comment