Relationships with no-op accessors fail during metamodel generation with NPEs
Description
Attachments
1
Activity
Show:

Andrea Boriero December 4, 2024 at 10:47 AM
Hi as commented on the PR hbm.xml
is deprecated and we are not planning to add any further improvement so I’m going to close the Jira.

Michael Hill May 3, 2019 at 5:23 PM

Michael Hill May 3, 2019 at 5:06 PM
I have a first pass (as a first-time contributor) PR that I'll be posting shortly.
Won't Fix
Created May 3, 2019 at 5:01 PM
Updated December 4, 2024 at 10:48 AM
Resolved December 4, 2024 at 10:48 AM
Summary
When defining Hibernate one-to-many and many-to-many (bag/etc.) mappings using
access="noop"
, session factory initialization fails. More specifically, JPA metamodel generation fails withNullPointerException
while trying to process metadata related toaccess="noop"
mappings.When processing JPA entity metamodels for any-to-many associations, Hibernate expects mapping metadata to point to a non-null
Member
. However, theaccess="noop"
handler (PropertyAccessStrategyNoopImpl.GetterImpl
) always returns a nullMember
. Null {{Member}}s are not handled, leading to NPEs.This is specifically an issue with entity metamodel generation and is not seen when disabling
hibernate.ejb.metamodel.population
.Background
I know that
access="noop"
is a "secret" undocumented feature, but this feature has been very useful for our team. We are a small team maintaining a large application and have built a fair amount of dynamic query features around Hibernate. These queries depend on several relationships that are managed by the application but which don't exist as DTO fields. We are able to take advantage of these relationships by combining thelazy="true"
andaccess="noop"
attributes.While this still technically works when using Hibernate criteria, it breaks when using the JPA metamodel. We recently upgraded from Hibernate 5.1.14 to Hibernate 5.4.2 and would like to begin our transition from Hibernate criteria to JPA.
Reproduction
Test case attached (to be added to
hibernate-core/src/test/java/org/hibernate/test/propertyref
).Stack trace: