Maybe the obvious question but I cannot find an elegant solution for it

In a Spring Service initialized from a multithreaded Controller I process a request from a 3rd party that contains a combination of a confirmation code and a terminal number. Once we process this request we persist this combination into the database and do not allow processing of this combination again.
The pseudo code is as follows:

```
protected void processAdmission(String confirmationCode, String terminalCode) 
throws AdmissionException {

    //Check availability in the database
    boolean isAvailable = checkDatabaseAvailability(confirmationCode, terminalCode);
    if (!isAvailable)
    {
        throw new AdmissionException();
    }
    saveInDatabase(confirmationCode, terminalCode);         
}

```

This unique combination is allowed only once to be processed; next time it should be an error because this combination is already in the database and we check the database . What if this unique combination comes twice simultaneously? The database protection will not help because the data are not in the database yet.