I am having a strange issue while inserting a new entry.
Problem: entityManager.persist(myEntiy)
: line is executed but no entry is created in the db.
I know many had this issue before and i have read all of those posts but none of it answers my problem. I am not inserting an entry for the first time. So i have did the configuration and other basic things right. That means I do use <tx:annotation-driven transaction-manager="jpaTransactionManager"/>
in my spring-core.xml and I do use an @Transactional
on top of the methods in my dao.
Solutions tried: Adding entityManager.flush()
after persist, but this resulted in
javax.persistence.TransactionRequiredException: no transaction is in progress.
Also tried:
em.getTransaction().begin(); em.persist(entity); em.getTransaction().commit();
which resulted in
Not allowed to create transaction on shared EntityManager
Then saw someone saying the problem may be the
AbstractSaveEventListener - delaying identity-insert due to no transaction in progress
but i didnt have anything in log saying that this may be the cause. And i dont have a clue what exactly is the solution if that is the issue. My hibernate log ends with the line.
DEBUG [80-exec-2 SqlStatementLogger.java: 104] select mySchema.sequence_for_my_entity_PK.nextval from dual
no errors whatsoever there. Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire