Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data model question

 
Thomas Becker
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I've a Bean which consists of three properties (country, timeframe, type).

[code]
public String country;
public String timeframe;
public String type;

...
getters/setters
...
[code]

Instances of that bean are not needed to be persistent.
But I want to have the possible values for the properties persistent. For example I want to have all allowed countries stored in a database and all possible types.

My approach (I don't like it at all) now would be to:

- Create three beans which will extend my simple entity bean and have only one property. One Bean for the countries where the property will be the countries, and so on.
- Create three tables with only two columns (e.g.: id, country)
- Map those beans to the tables via my HibernateDao

But that's quite nasty, since I've three additional classes and tables to store only few properties.

What I want to have in highlevel:

- Dynamically create links with QueryStrings for countries, type and timeframe from the persistent store. That's what I need the persistency for.
- When a user selects one of the links (for example one with the QueryString country=germany) his bean will get updated with the choosen country (setCountry("germany"). This is already working, but I've the links hardcoded in HTML and I want to have them generated dynamically.

What is a good datamodel/approach to get this done in a less spaghetti like way?! Does someone has an idea?

Looking forward to any replies! Maybe my whole approach is just stupid.

Thanks a lot!
Thomas
 
Emanuel Kadziela
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen (and afterwards satisfactorily used) the following approach. Create a Parameter object with two String fields (name, value) and a parameters table with three columns (oid, name, value) and a unique constraint on (name,value) and use it to store all your static parameters for all your objects. It does involve a semi-kludge where you have to have a naming convention for your Parameter.name(s), but if you stick with ognl expressions (i.e. package.BeanName.property) it gets pretty intuitive and clear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic