You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to upgrade the Hibernate version to 5.4.30.Final in my application, but this caused a NullPointerException during startup of the application. The problem only happens when deactivating optimistic locking for specific domain classes like this:
static mapping = {
version false
}
In a newly created grails-app this works, as the default Hibernate version used in the template is 5.4.18.Final.
As it seems from the Hibernate code, OptimisticLockStyle should not be null as it is an enumeration and this enumeration explicitely contains a constant NONE for the case where optimistic locking should be deactivated. It seems that GORM sets the optimistic lock style to null in case of a version false mapping, which in the end causes the statement optimisticLockStyle.isAllOrDirty() to fail with a NullPointerException.
Task List
Steps to reproduce provided
Stacktrace (if present) provided
Example that reproduces the problem uploaded to Github
Full description of the issue provided (see below)
Steps to Reproduce
create new grails app
create a domain class with version false mapping
update hibernate-core dependency in build.gradle to version org.hibernate:hibernate-core:5.4.30.Final
start application
Expected Behaviour
It should work.
Actual Behaviour
Application fails to start up with the following exception:
Caused by: java.lang.NullPointerException: null
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:390)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:609)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:128)
at sun.reflect.GeneratedConstructorAccessor69.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
... 53 common frames omitted
Environment Information
Operating System: Windows 10
GORM Version: 7.0.8
Grails Version (if using Grails): 4.0.9
JDK Version: 11
The text was updated successfully, but these errors were encountered:
I wanted to upgrade the Hibernate version to
5.4.30.Final
in my application, but this caused aNullPointerException
during startup of the application. The problem only happens when deactivating optimistic locking for specific domain classes like this:In a newly created grails-app this works, as the default Hibernate version used in the template is
5.4.18.Final
.The culprit seems to be the following code in hibernate-core:
https://github.com/hibernate/hibernate-orm/blob/dca2cabaf26fafb30baead8ba0e3d7229fb67c65/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java#L389-L390
In version 5.4.18 this was implemented like this:
https://github.com/hibernate/hibernate-orm/blob/ab9de8e428df4202ae9ed22787a5d90f2e87203a/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java#L380-L383
As it seems from the Hibernate code,
OptimisticLockStyle
should not be null as it is an enumeration and this enumeration explicitely contains a constantNONE
for the case where optimistic locking should be deactivated. It seems that GORM sets the optimistic lock style tonull
in case of aversion false
mapping, which in the end causes the statementoptimisticLockStyle.isAllOrDirty()
to fail with aNullPointerException
.Task List
Steps to Reproduce
version false
mappinghibernate-core
dependency inbuild.gradle
to versionorg.hibernate:hibernate-core:5.4.30.Final
Expected Behaviour
It should work.
Actual Behaviour
Application fails to start up with the following exception:
Environment Information
The text was updated successfully, but these errors were encountered: