Persist discriminator values for JOINED inheritance strategy (where present)

Description

When using @Inheritance(strategy = InheritanceType.JOINED) and @DiscriminatorColumn(name = "discriminator") you would assume any JPA provider to persist the correct @DiscriminatorValue into the discriminator column. But this doesn't happen with Hibernate 4 (and before). While this is not absolutely necessary I consider this a must as anybody would expect Hibernate to persist a discriminator if mapped.

As a member of the JPA expert group expressed it:

The spec does not require an implementation to use discriminator columns to implement JOINED inheritance, however, the assumption is that if @DiscriminatorColumn is specified then it would be used, i.e. the values would be written out. We do not explicitly state that if a @DiscriminatorColumn is specified in the code it must be used, just like we don't explicitly state that if a @Column or @JoinColumn is specified the values must be stored in the table, but there is only so much that we can or should specify. At the lowest level, certain laws of physics and reason are just assumed.

Please add this small feature, it would be a lot more consistent to common expectation and SINGLE_TABLE inheritance type.

Activity

Show:

Ka WuDecember 21, 2011 at 5:12 AM

Duplicate

Details

Assignee

Reporter

Priority

Created December 21, 2011 at 5:01 AM
Updated December 21, 2011 at 9:24 AM
Resolved December 21, 2011 at 9:24 AM

Flag notifications