java - Is there a better way to persist a map with the value being a set? -
java - Is there a better way to persist a map with the value being a set? -
i'm looked lot beingness able utilize hibernate persist map map<string, set<entity>>
little luck (especially since want on 1 table).
mapping multimaps hibernate thing seems referenced most, describes in detail how go implementing using usercollectiontype
.
i wondering, since written on 4 years ago, there improve way of doing now?
so, example, have on entitya
map map<string, set/list<entityb>>
.
there 2 tables: entitya
, entityb
(with entityb
having foreign key entitya
).
i don't want intermediate tables.
the way how done on current project transforming beans/collections xml using xstream:
public static string toxml(object instance) { xstream xs = new xstream(); stringwriter author = new stringwriter(); xs.marshal(instance, new compactwriter(writer)); homecoming writer.tostring(); }
and using lob type in hibernate persisting :
@lob @column(nullable = false) private string data;
i found approach generic , implement flexible key/value storage it. you don't xml format xstream framework has inbuilt driver transforming objects json. give try, cool.
cheers
edit: response comment. yes, if want overcome limitations of classic approach sacrifice indexing and/or search. stil implement indexing/searching/foreign/child relationships thru collections/generic entity beans - maintain separate key/value table property name/property value(s) think search needed.
i've seen number of database designs products flexible , dynamic(i.e. creation new attributes domain objects without downtime) schema needed , many of them utilize key/value tables storing domain attributes , references owner objects kid one. products cost millions of dollars (banking/telco) guess design proven effective.
sorry, that's not reply original question since asked solution without intermediate tables.
java hibernate map
Comments
Post a Comment