A public schoolboy who attacked two sleeping students and a teacher with hammers at a boarding school has been detained for life with a minimum term of 12 years after being found guilty of attempted murder.