By saying both code and name are unique... is this a composite key that must be 
unique or do both fields have to be unique?  If it is the composite key that 
must be unique than I would skip the checks and catch the exception when 
thrown.  Otherwise if each field must be unique then you need to validate each 
one and your design/logic is fine. 

>>> Anjib Mulepati <anji...@hotmail.com> 12/14/2011 3:21 PM >>>
Hi All,

I have question regarding use of validate() method in Struts 1.3.8.

I have simple form to collect couple of information (e.g. code and name) 
and have to add them to the Database. All database operations are 
handled by my DAO layer.

Both code and name are unique in Database. So I want to validate code 
and name before calling INSERT SQL statement.

Three methods I have in DAO layer are
      - Cutomer findByCode(String code);
      - Customer findByName (String name);
      - void createCustomer (Cutomer cust);

So I am calling first two methods in validate() method and third one in 
execute() method.

Is this a good way to do validation before inserting the record? Or 
there is better logic/design than this?

I will be glad if anyone can answer my curiosity.

Thanks,
Anjib




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org 
For additional commands, e-mail: user-h...@struts.apache.org 




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to