According to my understanding in hibernate (please confirm)
1- You have to session.close() if you get it by getSessionFactory().openSession()
session.close()
getSessionFactory().openSession()
You forgot to commit .You should to commit.
session.save(ac); // you should to add this bottom line session.getTransaction().commit();