Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Least Impact Design

Status
Not open for further replies.

DB2Problem

Programmer
Oct 17, 2002
53
US
Hi Java Guru's,

I am looking for least possible redesign of my java code.

The database has gone for a major change. Prior to this, my java program uses single primary key to identify the entity and on the basis of this key, I create the sets of java object (Which actually represent the tables in database). So logically each table is identifiable from the other by respective primary key (which is in fact one and only one).

The same key server as a foreign key for the other table, which has its own primary key. And so on. Each table is represented as java object.

But now the database tables have been given a different look. Each table is representation of a huge 5-6 fields serving as primary key (instead of old model of having just one primary key).

This model is not very different from the old one except each table has a combination of fields serving as primary key and referential integrity is served the same way as earlier.

Problem

My problem is huge code has been written out by considering one unique key. I need to know, how can I generate unique key from combinations of keys and use them with least possible java code modification. Can it be possible ..

You feedback will be a great help
 
You might think about writing some code-generation class which generates the .java files which represent your new data structure - ie connect to the database, extract the db table's metadata, and build up a class to represent this table automatically. Maybe a nightmare to begin with, but once implemented very easy to maintain !

Good Luck.
 
If your database produces XML documents of the schema you can use XSLT to generate Java code.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top