NullPointerException from Hibernate meta-model in native code #30259
Replies: 3 comments
-
/cc @Sanne(hibernate-orm), @gsmet(hibernate-orm), @yrodiere(hibernate-orm) |
Beta Was this translation helpful? Give feedback.
-
Please try to isolate the issue in a simple reproducer. Otherwise it's going to be hard to track what's going on. Thanks! |
Beta Was this translation helpful? Give feedback.
-
FYI no simple reproducer yet, but I have found a workaround. The old code used the meta-model statically. If I change that and initialize things when the objects are created instead, it works. Hibernate has had time to set the volatile fields by then. I'm fine with that for our purposes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a rather nasty problem that only happens in native code. We construct queries using the JPA Criteria API. There is an abstraction layer that translates user queries into criteria queries. This layer uses the meta model. Specifically, it uses fields like:
Our code references the SetAttribute, bSet in this case. When the application runs in Java mode, everything works. When it runs in native mode, it fails:
Looking at the code, it appears bSet is null. Either this is because the value was copied too soon (before Hibernate got around to setting the volatile field) in the native case or there is some reflection configuration or similar needed somewhere.
I'm not sure how to solve this. I can try adding indirection, so that our code stores a lambda that will look up the bSet value at runtime rather than setting it. Failing that I don't know.
Anyone else having similar problems with the meta model in native mode?
Beta Was this translation helpful? Give feedback.
All reactions