Jones (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMGQ3MzdjN2Rh...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16352?atlOrigin=eyJpIjoiMGQ3Mz...
) HHH-16352 (
https://hibernate.atlassian.net/browse/HHH-16352?atlOrigin=eyJpIjoiMGQ3Mz...
) DynamicUpdate and Statement/jdbc batch size leads to wrong parameter binding exception (
https://hibernate.atlassian.net/browse/HHH-16352?atlOrigin=eyJpIjoiMGQ3Mz...
)
Issue Type: Bug Affects Versions: 6.2.0.CR4 Assignee: Unassigned Components:
hibernate-core Created: 22/Mar/2023 06:03 AM Priority: Critical Reporter: Jones (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Given
* STATEMENT_BATCH_SIZE is enabled
* An entity with DynamicUpdate
When
* When changing multiple instances of a managed entity
Then
* An exception occurs trying to bind a parameter using the wrong generated sql
@DynamicUpdate
@Entity
@Table(name = "ENTITY_A" )
public class EntityA {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID" )
Integer id;
@Column(name = "PROPERTY_A" )
int propertyA;
@Column(name = "PROPERTY_B" )
int propertyB;
}
@Override
protected void configure(Configuration configuration) {
super.configure(configuration);
configuration.setProperty(AvailableSettings.SHOW_SQL, Boolean.TRUE.toString());
configuration.setProperty(AvailableSettings.FORMAT_SQL, Boolean.TRUE.toString());
configuration.setProperty(AvailableSettings.STATEMENT_BATCH_SIZE, "2" );
}
@Test
public void hhhXXXXTest() throws Exception {
// BaseCoreFunctionalTestCase automatically creates the SessionFactory and
// provides the Session.
try (Session s = openSession()) {
Transaction tx = s.beginTransaction();
EntityA entityA1 = new EntityA();
EntityA entityA2 = new EntityA();
s.persist(entityA1);
s.persist(entityA2);
tx.commit();
}
try (Session s = openSession()) {
Transaction tx = s.beginTransaction();
String hql = "select e from org.hibernate.bugs.EntityA e" ;
Query<EntityA> query = s.createQuery(hql, EntityA.class);
List<EntityA> actual = query.list();
actual.get(0).propertyA = 1;
actual.get(1).propertyA = 2;
actual.get(1).propertyB = 2;
s.flush();
tx.commit();
}
}
org.hibernate.exception.DataException: Unable to bind parameter #3 - 2 [Invalid value
"3" for parameter "parameterIndex" [90008-214]] [n/a]
at
org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:53)
at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:56)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:94)
at
org.hibernate.engine.jdbc.mutation.internal.JdbcValueBindingsImpl.lambda$beforeStatement$0(JdbcValueBindingsImpl.java:95)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at
org.hibernate.engine.jdbc.mutation.spi.BindingGroup.forEachBinding(BindingGroup.java:51)
at
org.hibernate.engine.jdbc.mutation.internal.JdbcValueBindingsImpl.beforeStatement(JdbcValueBindingsImpl.java:85)
at
org.hibernate.engine.jdbc.batch.internal.BatchImpl.lambda$addToBatch$0(BatchImpl.java:129)
at
org.hibernate.engine.jdbc.mutation.internal.PreparedStatementGroupSingleTable.forEachStatement(PreparedStatementGroupSingleTable.java:59)
at org.hibernate.engine.jdbc.batch.internal.BatchImpl.addToBatch(BatchImpl.java:114)
at
org.hibernate.engine.jdbc.mutation.internal.MutationExecutorSingleBatched.performBatchedOperations(MutationExecutorSingleBatched.java:60)
at
org.hibernate.engine.jdbc.mutation.internal.AbstractMutationExecutor.execute(AbstractMutationExecutor.java:45)
at
org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.doDynamicUpdate(UpdateCoordinatorStandard.java:939)
at
org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.performUpdate(UpdateCoordinatorStandard.java:279)
at
org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.coordinateUpdate(UpdateCoordinatorStandard.java:209)
at
org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2739)
at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:166)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:616)
at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:487)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:484)
at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:358)
at
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at
org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1412)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1398)
at org.hibernate.bugs.ORMUnitTestCase.hhhXXXXXTest(ORMUnitTestCase.java:80)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
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:833)
Caused by: org.h2.jdbc.JdbcSQLDataException: Invalid value "3" for parameter
"parameterIndex" [90008-214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:646)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.getInvalidValueException(DbException.java:298)
at org.h2.jdbc.JdbcPreparedStatement.setParameter(JdbcPreparedStatement.java:1395)
at org.h2.jdbc.JdbcPreparedStatement.setInt(JdbcPreparedStatement.java:359)
at org.hibernate.type.descriptor.jdbc.IntegerJdbcType$1.doBind(IntegerJdbcType.java:72)
at org.hibernate.type.descriptor.jdbc.BasicBinder.bind(BasicBinder.java:61)
at
org.hibernate.engine.jdbc.mutation.internal.JdbcValueBindingsImpl.lambda$beforeStatement$0(JdbcValueBindingsImpl.java:87)
... 38 more
Test scenario to be attached
(
https://hibernate.atlassian.net/browse/HHH-16352#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16352#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100219- sha1:eb3f1fe )