For what purpose?
Electric motors generally like spinning fast. Hydraulic motors generally don't. They're used in totally different applications. An electric servo motor and a gearbox can substitute for a hydraulic motor for a low-speed application. A hydraulic motor in a high-speed application just doesn't work very well.
And there's many types of electric motors, and many types of hydraulic motors, each suitable for different application.
More information = better answers.