I am using hibernate and spring mvc and using annotations .. I want that no parent entity should get deleted if children exists. Now I can do it explicitly by code , but can it be done directly via hibernate , I mean by configuration??
Secondly, In spring I am getting sessionFactory as and when (In every dao). To get session I use
sessionFactory.getCurrentSession()
should I get session/sessionFactory in a singeleton class and use it every where??
and I am using
sessionFactory.getCurrentSession().save(batch);
sessionFactory.getCurrentSession().delete(batch);
then I don't need to bother about closing and starting session, as it is done automatically. Is am correct?