Error org.hibernate.dialect.Firebirddialect does not support Identity key Generation

Asked

Viewed 88 times

0

This error appears when I go to save an entity in the database. I have configured the Entity class and the Repository in several ways, but the error remains. I am using Firebird 2.5.

The table automatically increments the id column by Trigger.

I ask for help because I don’t know how to solve this problem of entering a record being that the bank that is responsible for generating the id.

Log

Informações:   14.09.2017 18:24:19 [http-listener-1(3)] 36108 ERROR (default) java.lang.Object - org.hibernate.dialect.FirebirdDialect does not support identity key generation
Informações:   14.09.2017 18:24:24 [http-listener-1(3)] 41355 ERROR (default) java.lang.Object - Transaction already active

Below is the class Entity:

 @Entity
 @Table(name = "SMADISPO")
 public class SmadispoEntity {

     @Column(name = "ID_SMADISPO", table = "SMADISPO", nullable = false)
     @Id
     @GeneratedValue(strategy=GenerationType.IDENTITY)
     private Integer idSmadispo;

     @Column(name = "CODIGO", table = "SMADISPO")
     @Basic
     private Integer codigo;

     @Column(name = "DESCRICAO", table = "SMADISPO", length = 40)
     @Basic
     private String descricao;
 }

And below is the class that is running to save the entity in the database.

@Override
@Transactional
public <S extends T> S save(S entity) {
    try {
        entityManager.getTransaction().begin();

        if (!entityManager.contains(entity)) {
            entityManager.persist(entity);
        } else {
            return entityManager.merge(entity);
        }
        entityManager.getTransaction().commit();
        return entity;

    } catch (Exception e) {
        logger.error(e.getMessage());
        return null;
    }
}

Below is the table image in the bank and Trigger that generates the ID.

Estrutura da Tabela do banco de dados

Trigger que gera o ID.

  • You are clearly saying that Firbird does not support key generation with Identity. So you will have to change the Generationtype to another type (SEQUENCE, AUTO... depends).

  • I’ve changed, but still the error persists.

  • Puts the new code and new error message.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.