I have a data structure that boils down to:
class StylesheetUserPreferencesImpl {
long id;
String desc;
Map<String, Map<String, String>> nodeAttributes;
}
To try to make JPA2 annotations a little smarter, I created a small class to represent the inner class:
class LayoutAttributeImpl {
String nodeId;
private Map<String, String> attributes;
}
What gives me:
class StylesheetUserPreferencesImpl {
long id;
String desc;
Map<String, LayoutAttributeImpl> nodeAttributes;
}
In the end, I would like the table structure to look like this:
SS_USER_PREFS
PREFS_ID
DESC
SS_LAYOUT_ATTRS
PREFS_ID
NODE_ID
NAME
VALUE
I'm not quite sure how to do this, for example, in JPA. It looks like I want LayoutAttributeImpl to be nested, but as I understand it, Embeddable objects cannot contain collections. I am working right now with LayoutAttributeImpl, acting as a full-fledged @Entity, but this gives me an extra table that I really don't need.
source
share