Using the following entity configuration: {code:title=ParentEntity.java} @Entity @Audited @Inheritance(strategy = InheritanceType.JOINED) @DiscriminatorColumn(name = "type") public abstract class ParentEntity { @Id @GeneratedValue private Integer id; private String type; /** getter/setters **/ } {code} {code:title=ChildEntity.java} @Entity @Audited @DiscriminatorValue("child") public class ChildEntity extends ParentEntity { private String name; /** getter/setters **/ } {code}
Hibernate will insert **child** as the discriminator value on the ORM side; however, the fully qualified class name of the audited entity will be used in the envers audit tables.
{noformat} insert into ParentEntity_AUD (REVTYPE, type, id, REV) values (?, 'org.hibernate.test.stackoverflow.StackoverflowTest$ChildEntity_AUD', ?, ?) 09:08:25,631 TRACE BasicBinder:64 - binding parameter [1] as [INTEGER] - [0] 09:08:25,632 TRACE BasicBinder:64 - binding parameter [2] as [BIGINT] - [1] 09:08:25,632 TRACE BasicBinder:64 - binding parameter [3] as [INTEGER] - [1] {noformat}
In Hibernate 4.3.11.Final, this wasn't observed and the actual configured discriminator value was used instead. This also introduces a column width problem as column width is configured based on the expected configured values, which are often far shorter than the fully qualified name; causing insertion failures on the Envers side. |
|