# Hibernate 6.1.7.FINAL ignoring discriminator column on insertion

**URL:** <https://discourse.hibernate.org/t/hibernate-6-1-7-final-ignoring-discriminator-column-on-insertion/7940>\
**Category:** Hibernate ORM\
**Created:** [July 6, 2023, 12:47pm UTC](https://discourse.hibernate.org/t/hibernate-6-1-7-final-ignoring-discriminator-column-on-insertion/7940 "2023-07-06T12:47:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ccastro95](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/ccastro95/32/2554_2.png) [@ccastro95](https://discourse.hibernate.org/u/ccastro95)\
**Post date:** [July 6, 2023, 12:47pm UTC](https://discourse.hibernate.org/t/hibernate-6-1-7-final-ignoring-discriminator-column-on-insertion/7940/1 "2023-07-06T12:47:17Z")

</div>

After the **migration** of my project from spring boot 2 to **spring boot 3** and updating the **hibernate** version to **6.1.7.Final**. I’m encountering some problems with something that worked before.

Hibernate seems to ignore the insertion of the discriminator value on creation.

Example:

```auto
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = Book.BOOK_TABLE_NAME)
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Book {

    public static final String IDBOOK = "IDBOOK";
    public static final String BOOK_TABLE_NAME = "BOOK";

    @Id
    @Column(name = IDBOOK)
    private Long id;

    @Column(name = "TYPE", insertable = false, updatable = false)
    private String type;

    ....
}

@Entity
@DiscriminatorOptions(force = true)
@DiscriminatorValue("PERIODIC")
@Table(name = "PERIODIC")
@PrimaryKeyJoinColumn(name = "IDPERIODIC")
public class Periodic extends Book {

    ...attributes
}

@Entity
@DiscriminatorOptions(force = true)
@DiscriminatorValue("CODE")
@Table(name = "CODE")
@PrimaryKeyJoinColumn(name = "IDCODE")
public class Code extends Book {

    ...attributes
}

```

After executing the create method on the BookRepository and inspecting the generated code by hibernate I found out that is not adding the type value:

```auto
insert 
    into
        book
        (*"...many values except type"*, idbook) 
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: 
    insert 
    into
        periodic
        (..., idperiodic) 
    values
        (?, ?, ?, ?, ?)

```

The result of this insert is the column type taking its default value in the database and ignoring the right type.

I tried removing the type attribute or removing the insertable = false so that hibernate will try to insert it. None of these worked.

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [July 13, 2023, 5:12pm UTC](https://discourse.hibernate.org/t/hibernate-6-1-7-final-ignoring-discriminator-column-on-insertion/7940/2 "2023-07-13T17:12:39Z")

</div>

6.1 is not maintained anymore. Update to Spring 3.1 which ships with Hibernate 6.2.
