This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Representing types in creational db code Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Representing types in creational db code" Watch "Representing types in creational db code" New topic
Author

Representing types in creational db code

Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
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?
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Representing types in creational db code
 
Similar Threads
B&S: Record and Contractor classes
[B&S] Create Method
Capture list of checked rows from JSP
how to delete the rows which are checked
Exceptions in URLyBird