0 Replies Latest reply on Mar 10, 2006 6:12 AM by Goran Ehrsson

    I want the discriminator column for other purposes

    Goran Ehrsson Newbie

      I know that Hibernate don't need a discriminator column for joined subclasses but that makes it hard for me to create an index that I want.
      Lets say I have entity classes A, B, and C.
      B and C are extending A with inheritence type = joined. I have a sequence number property in A that must be unique within each subclass. I.e. B can only have one instance with number 42 and C can only have one instance with number 42. I want to create a combined unique index on (a.discriminator, a.number).

      Can I force a discriminator column? Or how do I easiest keep a field that simulates discriminator column i A in sync with discriminator values for future sub-classes and modifications?

      I guess I can read the @DiscriminatorValue annotation at runtime and store it in my own column with @PrePersist. Is that a recommended approach?