Easy Access to Primary Keys in Transfer Objects
Posted At : August 22, 2008 7:43 AM | Posted By : Bob Silverberg
Related Categories: ColdFusion, Transfer
I just added a couple of new methods to my AbstractTransferDecorator to make some of my ColdFusion development tasks easier. I found that when trying to write abstract code I needed to know the name of the primary key column of my object, and also sometimes needed to know the value of that column for the current object. So I wrote two new methods to address those needs:
- __getPKColumn() - Returns the name of the id column for the current object.
- __getPKValue() - Returns the value of that column for the current object.
I chose to prefix the method names with a double underscore so I wouldn't end up overwriting the getters if any of my objects ever have those names as properties. Although I'm fairly certain that would never happen it seems like a good idea nonetheless. Here's the code: