I had this problem when we first got the car.
Your right, the sensor is intergrated into the locking mech of the car and you will need to buy a new lock.
They are quite cheap.
The reason it goes is because the liquid from the washer bottle drip down onto the lock and in time the sensor fails.
The cure we found was never to use the rear washer but just the wiper.
I blocked the end of the pipe off further down with a bolt stuck down the hole.
As for refitting a new lock this I found tricky.
You need to remove the interior panel on the hatch.
Then atttcah new lock.
Climb into the boot with rear seats down and get someone to close the hatch.
That way you can position the lock, so when shut push the lock upwards so it is just holding the ring, so that you get a secure lock then climb out and unscrew the rubber bumpers either side so there is no lateral movement on the boot lid.
If not done the lid tends to bounce on the lock.