Code:
public String execute () {
if (userDAO.isDuplicateUsername(uname)) {
return "invalid";
} else {
userDAO.makePersistent( new User(uname) );
return "success";
}
}
If something bypasses this code to create a user, you have a bug in your application. The job of the database constraint on the UNAME column is going to take care of this and throw an exception if you do it wrong. Sometimes "business logic" really means just a simple constraint, and sometimes you can't enforce a relation-level constraint, such as UNIQUE, in a Java data model, because Java doesn't have relations.