I am trying to build a hibernate layer on top of an existing database.
This existing database has few foreign keys/ constrains; it used to rely on storeproc to update, so that it hopefully could maintain data integrate. Most of the tables use composite key as primary key
Some tables here: Profile, Address, ProfileAddress Profile primary key: profileId + profileVersion Address primary key: addressId + addresVersion ProfileAddress primary key: profileId + profileVersion +addressId
there is not constrain between these tables..
I tried to map these tables in a way that ProfileAddress can return Profile object or even better return address as well.. eg, profileAddress.getAddress, getProfilel. So far, I have no luck; I saw most of the hibernate mapping example, they mostly using a single column as a key column, i wonder if this is possible to do with composite key, also there is no foreign key references.
Another weird thing about this db is, some entities are versioned in their tables. For example, when a profile is update, it adds a new row of profile with different version number and the old row still lives in the same table...
I wonder the version tag can be used for this case, given version is part of the primary key
Any insight are appropriated. Thanks for your help!
|