added session factory, fixed User sql queries