a little modified with the generichibernatedao