I had found a solution for this. Around the farm dig 3 cubes depth and 1 cube length. So villagers cannot climb or cross that distance. But you can easily jump from that one cube length.
Sorry for my english. But try to understand this. This will work.
Another tip is some times provide a small bridge for the villagers to pass, so that they will plant the seeds for you. But after they go to sleep collapse the bridge. So that they cannot take that take the wheat.
I am following this technique and it's working. I am exploiting the villagers. I am following this technique and using them for my purpose.