I have this class which is dedicated to persist data in db through persistance layer of hibernate.
public class TLinkEquipementDAOImpl implements TLinkEquipe
I just came across this problem, and now I had solved it. But I realize that I was so stupid.
the reason I find is that the data I want to commit has a foreign key but I forget that, so the transaction will always close itself. I add the foreign key in the database, and then the test or main method run successfully.
the Key point I want to say is that please write this in your code.
} catch (Exception ex) {
ex.printStackTrace();
tx.rollback();}
and you will easily find the reason why the transaction closed or not alive. that is my experience,hope useful!