Transaction not active - Hibernate - JPA

前端 未结 4 765
北恋
北恋 2020-12-19 07:02

I have this class which is dedicated to persist data in db through persistance layer of hibernate.

public class TLinkEquipementDAOImpl implements TLinkEquipe         


        
4条回答
  •  有刺的猬
    2020-12-19 07:46

    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!

提交回复
热议问题