Op I am another poster who has been in this situation. More than once actually 
It is an insidious form of self harm which causes us to feel much shame
We get into the situation because our self esteem is lacking, then being treated with a lack of respect lowers it further, which makes us chase harder, which makes the other person treat us with yet more disregard, which makes us feel worse and so chase even harder, and on and on it goes becoming ever more difficult to extricate ourselves. Whoever likened it to a hamster wheel was dead on.
What we are chasing is some validation that we are desirable and worthwhile. Because we don't feel it ourselves we are looking to someone else to give it to us. If we win this man over then that means we are ok! But we are setting ourselves us to fail.
The only possible way to make this pain stop is to... stop. We have to change the outcome for ourselves by behaving differently. Because if we keep doing what we have always done we are going to keep getting what we've always got.
I can understand why, to someone with a healthy enough sense of self worth, this behaviour seems inexplicable. I can see why someone would look at this miserable pattern and think, how could anyone be so weak? How could anyone do this to themselves??? But humans do all kinds of crazy things that are not in their best interests. I can relate to the op but draw a total blank when trying to understand why some people, for example... I dunno... stuff themselves with junk food to comfort themselves emotionally. Lots of people do it. But it would make me feel very ill and so I don't personally get it. I don't go around calling them fat, greedy bastards though.
As for what to do OP, that is ultimately up to you. Lots of people are suggesting going cold turkey with a rip the plaster off approach ie block him and never speak to him again. I personally can't do that and fair better with a gentler approach that involves kind of weaning myself off. I start by getting busy/going away if I can. I stop initiating contact but do still respond to contact initiated by the other person. However I don't make effort to continue the conversation by asking questions. I answer, "Fine thanks" to queries as to how I'm doing and leave off the, "And you?" for example. Gradually I begin to feel stronger. And as my confidence returns little by little, I begin to want the person less (oh the relief!)
I am getting better at recognising these situations for what they are far sooner these days and beginning the process outlined above, earlier. So whereas before I might have gone on for months making myself miserable, now after one or two meaningless shags with minimal effort from the other person I go aha - I recognise this! Ok, let's start treating myself with more care... And as my self care improves I feel better about myself 