Mistake of transaction



  • Hello. I use Tomcat OpenEJB. When calling method em.persist(myObj);That's a mistake.

    javax.ejb.EJBTransactionRolledbackException: Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization at org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException (BaseEjbProxyHandler.java:341)
    ♪ ♪ ♪

    Caused by: javax.transaction.RollbackException: Unable to commit: transaction marked for rollback at org.apache.geronimo.transaction.manager.TransactionImpl.commit (TransactionImpl.java:271)
    ♪ ♪ ♪

    Maybe who has ideas how to help me? My class looks like this:

    @PersistenceContext(unitName = "todolistUnit", type = PersistenceContextType.TRANSACTION)
    private EntityManager em;
    public void addTask(String task, Timestamp endDate, Integer categoryId) {
        TlTasks tasks = new TlTasks();
        tasks.setTask(task);
        tasks.setEndTime(endDate);
        tasks.setCategoryId(categoryId);
        em.persist(tasks);
    }
    


  • The error was in the class of substance declaring the table.

    @javax.persistence.Table(name = "TL_Tasks", schema = "dbo", catalog = "todoListDB")
    @Entity
    public class TlTasks {
    private int id;
    

    @javax.persistence.Column(name = "id", nullable = false, insertable = false, updatable = false, length = 10, precision = 0)
    @Id
    public int getId() {
    return id;
    }

    In pole proclamation
    insertable = false, updatable = false standing. true♪ There was a mistake at this stage.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2