• 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?
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!