You got my problem quite right.
The idea of adding a dedicated primary-key column to the description table sounds quite nice and I think it'll help getting me further with my OR-mapping.
My gread advantage is, that I can setup the DB according to my needs. However, I'd like to specifiy the mapping with XDoclet within the Java layer for having all datamodel issues in one central place of the application for providing more flexibility and better maintainability.
From the DB point of view I would model the ER as follows:
I have an entity table and a description table.
The description table has a composite-key consisting of the corresponding entity-id and the iso-language code (or, as I got from your post, a dedicated primary key). So, there may be more than one row in the description table belonging to an entity.
On the java side, I have an entity and a description class. The description class contains two Maps (in detail: HashMaps), one for title and one for description and a set containing the iso language codes a description/title exists for. Now, my question here is, is it possible to map my java description class to the description table with XDoclet (how can I tell XDoclet to create a unique constraint on two columns)? Or do I have to write the hibernate xml mapping on my own instead? Is it possible, to map multiple rows of one table to one java object? The other possibility would be, of course, that I setup the tables in a different way, but I think it would be convenient to create the tables as described above.
Chris
|