The body produces antibodies against H1N1 (Swine flu) naturally on contact with the virus or when an individual is vaccinated against H1N1 (Acquired Immunity). The body after mounting a defense against this virus and fighting this virus, also produces immune cells which will always remember this strain, H1N1. So the next time this virus passes the barriers of the body and enters the body, these immune cells remember this strain quickly, and a strong, more defined and well co-ordinated response will occur.
Now, sometimes the virus mutates and the body does not recognize that strain and no strong reaction occurs. This sometimes happens at times during pandemics, when lots of people have been affected and the virus is widespread. This is one of the main reasons there are yearly, seasonal vaccinations for 'flu'.
Now, it is highly unlikely for a person to be re-infected with the 2009 H1N1 ( swine flu) virus, but it is Possible.
There have been three(3) confirmed cases of reinfection with H1N1 in Chile
http://www.ncbi.nlm.nih.gov/pubmed/20031070
A good article on 2009 Influenza A (H1N1) (Swine Flu) in medpedia below;
http://wiki.medpedia.com/Swine_Influenza