Bytecode enhancement leads to broken constructor for a generic embedded field in a MappedSuperclass
Description
Affects ORM 6.3 (current main) and 6.2.5, at least. I think 6.2.4 and below were a bit less affected, because they didn’t detect composite fields correctly (see HHH-16774), so one might not have noticed when using e.g. @EmbeddedId, but the bug was already there when using @Embedded.
With the following model, one will get this exception when calling MyEntity’s constructor:
Model:
The bug also affects @EmbeddedId, but that seems irrelevant.
Workaround for those affected: change the visibility of the field annotated with @Embedded/ @EmbeddedId to protected (or the default package-private visibility if the mapped superclass and subclass are in the same package). This will cause Hibernate ORM to generate different bytecode unaffected by this bug.
Affects ORM 6.3 (current main) and 6.2.5, at least. I think 6.2.4 and below were a bit less affected, because they didn’t detect composite fields correctly (see HHH-16774), so one might not have noticed when using e.g.
@EmbeddedId
, but the bug was already there when using@Embedded
.With the following model, one will get this exception when calling
MyEntity
’s constructor:Model:
The bug also affects
@EmbeddedId
, but that seems irrelevant.I will submit a PR with a reproducer ASAP.