This affects Hibernate ORM 6 *and* 5.6.
Reproducer: [https://github.com/hibernate/hibernate-orm/pull/5449|https://github.com/hibernate/hibernate-orm/pull/5449|smart-link]
This is only relevant with bytecode enhancement enabled to get [lazy basic properties]([https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#BytecodeEnhancement-lazy-loading|https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#BytecodeEnhancement-lazy-loading]).
Updating such lazy properties does not seem to work correctly:
* When properties are assigned to fetch groups, there is only one problem: setting a lazy property to null is ignored, the entity is not updated. * When properties are *not* assigned to fetch groups: ** setting a lazy property to null is ignored, the entity is not updated. ** setting a lazy property to a non-null value is ignored, the entity is not updated. ** changing only a single lazy property on an entity that has only lazy properties will lead to an exception: {noformat} java.lang.IllegalArgumentException: sql must be non-null.
at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.getBatchStatement(AbstractBatchImpl.java:127) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3544) at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3470) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3887) at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:136) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:615) at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:486) at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:483) at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:329) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39) at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1422) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:476) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2233) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1929) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:439) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101) at org.hibernate.testing.transaction.TransactionUtil.doInHibernate(TransactionUtil.java:372) at org.hibernate.orm.test.bytecode.enhancement.lazy.basic.OnlyLazyBasicUpdateTest.updateSomeLazyProperty(OnlyLazyBasicUpdateTest.java:57) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.lang.Thread.run(Thread.java:829){noformat}
Reproducer: [https://github.com/hibernate/hibernate-orm/pull/5449|https://github.com/hibernate/hibernate-orm/pull/5449|smart-link] |
|