This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

Representing types in creational db code

 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm looking for wisdom on the following situation.

I have a fairly standard situation where one table in the database references another, with the latter table representing a set of type values.

I have DAOs representing records from both tables, and I'm trying to work out the best way of using the types in a creational sense.

For example,

Record r = new Record();
... populate fields
recordDAO.insert(r);

Now, in my business logic, there may be a requirement to create records of a certain type. For example,

r.setType( Type.getByUID( Type.STANDARD_TYPE ) );

As you can see, at the moment I am using some enumerated fields in Type DAO to correlate to unique values in the underlying table. These are guaranteed unique character identifiers.

This doesn't feel right. Of course I can factor out the UIDs to a configuration file, but this doesn't change the fact that the code still needs to know how to create a "STANDARD_TYPE".

Any suggestions of a better approach to this, without changing my current persistance layer entirely?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic