A public schoolboy who claimed he was sleepwalking when he tried to murder two students and a teacher in a claw hammer attack has been detailed for life with a minimum term of 12 years.