For info on Spanish Rail, routes and prices and tickets take a look at
http://www.spanish-rail.co.uk/
I think there may be a train from Lorca that goes up to Montpelier in France stopping at Barcelona, not sure if Valencia is also a stop.
I would allow up to 3 hours driving and bear in mind the A7 is at it's busiest around Valencia