Let's say that I have a service in which I want to check a transaction
table for a pre-existing record using a field other than the key id
column. I'm wondering about placing tid bit functions for a
requirement like this in the gateway or what? For example, would this
be a good practice:
transactionService.cfc:
public void function processTransaction(){
var transactionid =
transactionsGateway.checkTransactionByTXNID(rc.txn_id);
if(transactionid eq 0){
recordTransaction(rc);
}else{
//transaction already exists
}
}
transactionGateway.cfc:
public any function checkTransactionByTXNID(numeric txn_id){
var transactionid = 0;
sql.new query(sql="select transactionid from transactions where txn_id
= #txn_id#");
result = sql.execute().getResult();
if(result.recordCount gt 0){transactionid = result.transactionid;}
return transactionid;
}
Not concerned with code correctness, just typed it in for general
idea. Wondering if checking for a duplicate transaction record from
the gateway is correct or should I use the bean (active record)? Or
DAO, etc..? Ideas?? Maybe it's just a matter of preference, seems OO
is more art than standards sometimes with various styles.