I have a mapping question.
I have a person table that is shared by many applications. instead of continually adding new columns for application specific data we would like to have a separate table where these settings are added as rows with a column for the setting type.
Actually we have many tables that need this feature person/office/company/contact.
We would like to be able to do something like person.getSettings().getSetting1() which would return a string/integer/boolean depending on the type of setting. We want this property to be mutable so all we need to do is call person.getSettings().setSetting1(newvalue) to update the value. We also want to be able to use this property in a query "where person.settings.setting1 = 'test' ". We also want each property to be lazy loaded so its only queried when we need it.
Our original plan was to have one common settings table, and one common 'setting type' table. then create a many to many table for each entity. But we are ok with modifying this table structure if it means a easier mapping process.
I have seen the <component> tag with looks like it will get us the person.getSettings(), but I'm not sure where to go after that. I know I can do a <set><many-to-many> with a where clause, but that would return a list of Setting beans. I saw that if I change the table structure to use one settings table per entity, and eliminate the setting type table, I can use 23.4.1. "Typed" one-to-one association. but that would mean I need to person.getSettings().getSetting1().getValue(). and adding a new setting becomes more complicated because I need to create the Setting object (assumable with the correct type set by me),then set its value, and then call person.getSettings().setSetting1(newSettting)
I'm hopping there is a best practice for this type of situation, and that I just don't know the right search terms.
Thanks
Dave
|