I'm encountering somewhat of an, uh, unorthodox design and I'm not quite sure how to handle it. The table I'm trying to map looks like:
TABLE example {
ID INT,
CATEGORY VARCHAR,
PROPERTY VARCHAR,
VALUE VARCHAR);
A single id can have several rows (obviously, not a primary key). As an example, it could look like:
# ID CATEGORY PROPERTY VALUE
1 general_info name order 1
1 general_info date 1/1/2009
...
Every ID might have several different categories for it. Property names are unique for any given (id, category) combination.
(EDIT) The ID field is a foreign key to objects in a different table. I need to be able to get from these objects to the various properties stored in this table, using only the ID field. If a composite key is the way to go, how do I then link them?
(EDIT2) I also think the detail you're missing here is that all the data with the same ID in column one conceptually belongs to the same object. I don't want a separate instance for every (ID,CATEGORY) combination.
Obviously, this isn't very normalized. Worst case scenario, I set up some extra tables that are normalized and copy everything over, but I was wondering if anyone could suggest a sensible way to get this information into hibernate backed objects directly? If necessary in some sort of bag of String properties.
I'm using hibernate-annotations btw.