Hi, the company I work for has a Hibernate mappings for entities model - this was created from scratch, well designed and has all correct, working mappings - it works with Derby database. Now we want to use the created entities and create just mapping files to be able to read legacy data from another database, which has slightly different schema, but similar enough to try to map it using our Java entity classes. Unfortunately there are a lot of situations in that legacy DB where value - represented in new schema as just e.g. String - is kept in separate table and referenced via ID. The following example will put more light on this configuration:
TableA - id, name, description, tableB_id TableB - id, name
whereas Java classes are: EntityA - id, name, description, nameFromEntityB EntityB - shouldn't really exists, since it is not needed
So in order to represent EntityA in full, we would have to load just the name from TableB using TableA.tableB_id = TableB.id relation, but what actually interests us from TableB is just the name, and it should be stored in a String field (nameFromEntityB) in EntityA class (the new schema and mappings got rid of this unnecessary TableB and keep the name as a string value in TableA).
Is it possible to construct HBM mapping file to achieve this?
Thank you in advance for any help.
|