struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Reed" <ERE...@MAIL.NYSED.GOV>
Subject Re: use of validate() method [S 1.3.8]
Date Wed, 14 Dec 2011 20:31:00 GMT
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 <> 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.


To unsubscribe, e-mail: 
For additional commands, e-mail: 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message