Log a warning instead of throwing an Exception when @AttributeOverride is used in conjunction with inheritance
Description
caused by
Activity

Gavin KingMarch 10, 2024 at 4:43 PM
Via a test that made no sense at all, I just discovered this issue.
To recap: Hibernate has, AFAICT, never respected the use of @AttributeOverride
on a subclass in an entity hierarchy. (It can be usefully used when inheriting a @MappedSuperclass
.)
So the request in this issue was to not throw an exception but instead just log a warning and just ignore the annotation.
This is a terrible idea and incredibly hostile to users.
I am now changing Hibernate to throw the exception it should always have thrown.

Former userFebruary 19, 2019 at 6:13 AM
Fixed in 5.3 branch as well.

Petar TahchievDecember 22, 2018 at 3:37 PM
Hi @GailBadner, no in 5.2.x the @AnnotationOverride
had no effect. Then in 5.3.x it started throwing exception. This ticket tackles the exception. Shall I raise another one for the AnnotationOverride
not working, or can we address it here?
Andrei IvanovDecember 21, 2018 at 8:12 PM
The problem is that I'll have to convince the Log4J team the change is necessary, even though it works with Hibernate versions earlier than 5.4 and with Eclipselink, and it will takr a very long time to get a release with such changes 😟
I really was hoping to be able to switch to Java 11 soon.

Former userDecember 21, 2018 at 7:57 PM
, I understand that no exception was thrown in 5.2. Did an @AttributeOverride
actually work properly when mapped on an entity class in a TABLE_PER_CLASS
hierarchy? It would help a lot if you could add a test case to your PR that shows that it is actually working (overriding the column name) with your fix.
, According to the spec, @Inheritance(...)
"is specified on the entity class that is the root of the entity class hierarchy". The spec also says a mapped superclass "is not itself an entity". IOW, a mapped superclass should not be annotated with @Inheritance
. SINGLE_TABLE is the default for inheritance hierarchies, so simply removing @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
from AbstractLogEventWrapperEntity
should fix that.
This issue is a spin-off of https://hibernate.atlassian.net/browse/HHH-12609
As discussed there when the user is using Inheritance strategy TABLE_PER_CLASS it is a perfectly valid case, but instead the current implementation in 5.3 throws an exception (5.2 works fine though). To fix this I have added an extra check - please see https://github.com/hibernate/hibernate-orm/pull/2706