# Role Column in a second Inheritance strategy

**URL:** <https://discourse.hibernate.org/t/role-column-in-a-second-inheritance-strategy/6452>\
**Category:** Hibernate ORM\
**Created:** [July 1, 2022, 6:36am UTC](https://discourse.hibernate.org/t/role-column-in-a-second-inheritance-strategy/6452 "2022-07-01T06:36:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Romain](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Romain](https://discourse.hibernate.org/u/Romain)\
**Post date:** [July 1, 2022, 6:36am UTC](https://discourse.hibernate.org/t/role-column-in-a-second-inheritance-strategy/6452/1 "2022-07-01T06:36:55Z")

</div>

Hi !

Actually I have a mother class with a JOINED inheritance. This class has a child class which is also a mother class and abstract with a SINGLE TABLE inheritance.

The problem is :  
If I set a Discriminator Column on the SINGLE TABLE mother class, it wont’ apply the Discriminator Column on this class.

How can I set a Discriminator column on my abstract class table

```auto
@Entity
@Inheritance(strategy = JOINED)
public class DiagnosticGenerique extends Diagnostic {
(...)
}

@MappedSuperclass
@DiscriminatorColumn(name = "ROLE", columnDefinition = "varchar2(120)")
@Inheritance(strategy = SINGLE_TABLE)
@Table(name = "TDIAGNOSTICCHAUDFROIDURBAIN")
public abstract class AbstractDiagnosticChaudFroidUrbain extends DiagnosticGenerique {
(...)
}

@Entity
@DiscriminatorValue(value = "DiagnosticChauffageUrbain")
@Table(name = "TDIAGNOSTICCHAUDFROIDURBAIN")
public class DiagnosticChauffageUrbain extends AbstractDiagnosticChaudFroidUrbain {
(...)
}

```

---

<div class="post-metadata">

**Author:** ![dreab8](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/dreab8/32/25_2.png) [@dreab8](https://discourse.hibernate.org/u/dreab8)\
**Post date:** [July 1, 2022, 9:32am UTC](https://discourse.hibernate.org/t/role-column-in-a-second-inheritance-strategy/6452/2 "2022-07-01T09:32:39Z")

</div>

Hi @Romain ,

unfortunately in Hibernate you cannot mix Inheritance strategies.  
For a good article about this topic [Mixing Inheritance Mapping Strategies with Hibernate](https://thorben-janssen.com/hibernate-mix-inheritance-mappings)

---

<div class="post-metadata">

**Author:** ![Romain](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Romain](https://discourse.hibernate.org/u/Romain)\
**Post date:** [July 1, 2022, 9:38am UTC](https://discourse.hibernate.org/t/role-column-in-a-second-inheritance-strategy/6452/3 "2022-07-01T09:38:29Z")

</div>

Well, I understand it.

But then, why in the JavaDoc of the DiscriminatorColumn class we have that :

> Specifies the discriminator column for the SINGLE\_TABLE and JOINED Inheritance mapping strategies.  
> The strategy and the discriminator column are only specified in the root of an entity class hierarchy or subhierarchy in which a different inheritance strategy is applied  
> If the DiscriminatorColumn annotation is missing, and a discriminator column is required, the name of the discriminator column defaults to “DTYPE” and the discriminator type to DiscriminatorType.STRING.

The part that catches my eye

> or subhierarchy in which a different inheritance strategy is applied

Which mean that it’s possible right ?  
Or maybe possible in differents ORM but not in Hibernate ?

---

<div class="post-metadata">

**Author:** ![dreab8](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/dreab8/32/25_2.png) [@dreab8](https://discourse.hibernate.org/u/dreab8)\
**Post date:** [July 1, 2022, 10:15am UTC](https://discourse.hibernate.org/t/role-column-in-a-second-inheritance-strategy/6452/4 "2022-07-01T10:15:17Z")

</div>

JPA and Jakarta specs does not require support for the combination of inheritance strategies, and Hibernate does not support it but yes it may be possible implementations support it.

As stated in [Jakarta Persistence](https://jakarta.ee/specifications/persistence/3.1/jakarta-persistence-spec-3.1.html#a14891)

> Support for the combination of inheritance strategies is not required by this specification. Portable applications should only use a single inheritance strategy within an entity hierarchy.

---

<div class="post-metadata">

**Author:** ![Romain](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Romain](https://discourse.hibernate.org/u/Romain)\
**Post date:** [July 1, 2022, 11:41am UTC](https://discourse.hibernate.org/t/role-column-in-a-second-inheritance-strategy/6452/5 "2022-07-01T11:41:12Z")

</div>

Okay, it’s clearer now.
