# Rollback does not work on MyISAM storage engine with Hibernate and MySQL

**URL:** <https://discourse.hibernate.org/t/rollback-does-not-work-on-myisam-storage-engine-with-hibernate-and-mysql/2077>\
**Category:** Hibernate ORM\
**Created:** [January 17, 2019, 4:15pm UTC](https://discourse.hibernate.org/t/rollback-does-not-work-on-myisam-storage-engine-with-hibernate-and-mysql/2077 "2019-01-17T16:15:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tchadrack](https://avatars.discourse-cdn.com/v4/letter/t/e79b87/32.png) [@tchadrack](https://discourse.hibernate.org/u/tchadrack)\
**Post date:** [January 17, 2019, 4:15pm UTC](https://discourse.hibernate.org/t/rollback-does-not-work-on-myisam-storage-engine-with-hibernate-and-mysql/2077/1 "2019-01-17T16:15:49Z")

</div>

I am doing some tests with hibernate but the rollback seems to not be working with the Mysql database MyISAM.

I have an Entity called “Person”, that have a property poiting to same class (Person)

like this:

```auto
@Entity
public class Person {

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "pessoa_id")
    private Person conjuge;
    
    @Column(unique = true)
    private String document; 

}

```

Then I have a generic DAO:

```auto
 public void save( T entity ){
          try {
            
              getCurrentSession().beginTransaction();
              getCurrentSession().saveOrUpdate( entity );
              getCurrentSession().getTransaction().commit();
          } catch (Exception e) {
              getCurrentSession().getTransaction().rollback();
              System.out.print(e.getMessage());
              System.out.print("error............");
          }

   }

```

When I set the Person.conjuge property to another Person and call this save method, and if I set the main person with the same document property it will throw an excpetion, because the field “document” is unique, and it is ok.

But that rollback is not working and the conjuge Person continues being inserted into the table,  
What am I missing here?

---

<div class="post-metadata">

**Author:** ![tchadrack](https://avatars.discourse-cdn.com/v4/letter/t/e79b87/32.png) [@tchadrack](https://discourse.hibernate.org/u/tchadrack)\
**Post date:** [January 17, 2019, 4:38pm UTC](https://discourse.hibernate.org/t/rollback-does-not-work-on-myisam-storage-engine-with-hibernate-and-mysql/2077/2 "2019-01-17T16:38:32Z")

</div>

Ok, I changed the mysql dialect to InnoDB, and it worked.

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [January 17, 2019, 4:40pm UTC](https://discourse.hibernate.org/t/rollback-does-not-work-on-myisam-storage-engine-with-hibernate-and-mysql/2077/3 "2019-01-17T16:40:07Z")

</div>

> [@tchadrack](#):
>
> I am doing some tests with hibernate but the rollback seems to not be working with the Mysql database MyISAM.

MyISAM does not support transactions. Only InnoDB is a transactional storage engine. Anyway, InnoDB is the default storage engine, so why did you choose MyISAM in the first place?
