Although this is not my area, If I may speculate on your question...
Water borne pathogens of some sorts can indeed be ingested and over time an immunity can be built up to them. Many feacal colliforms that can make a person sick can actually have no effect whatsoever on a person who has built up an immunity to them while knocking someone else on their ass.
Now that being said, bacteria of a "food poisoning" nature (salmonella, botulism,etc.) are in my mind extreeemly difficult to build an immunity to. The serious forms of food poisoning such as sal and bot are quite frankly DEADLY. Beleive me, you do NOT want botulism or salmonella. I would suspect that in these instances it would come down to just how much of the bacteria you have injested. Can your body fight off the bacterial infection? (e.g. is it a "squad" of bacteria, or a "battalion"?).
As for such infections as ecoli H0157 I think that you can build a immunity to it to a certain degree, but it wouldn't be anything that would happen in a casual way. Maybe in a lab setting. 157 ranks right up there with bot. and sal.
One point of note is that often when we get that nasty 24 hour bug, it's usually food poisoning of a "lesser" nature. There is no 24 hour flu either (doesn't exist), instead it's likely ol "who flung poo's" chinese chicken that's boiling in your bowels.
I'm just speculating here though.