[JIRA] (HHH-16395) Initialization of Hibernate Proxies for Abstract Entities can fail
by Thorsten Goetzke (JIRA)
Thorsten Goetzke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6422e66... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTMxNWE3OTU4... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16395?atlOrigin=eyJpIjoiYTMxNW... ) HHH-16395 ( https://hibernate.atlassian.net/browse/HHH-16395?atlOrigin=eyJpIjoiYTMxNW... ) Initialization of Hibernate Proxies for Abstract Entities can fail ( https://hibernate.atlassian.net/browse/HHH-16395?atlOrigin=eyJpIjoiYTMxNW... )
Issue Type: Bug Affects Versions: 6.2.0.CR4 Assignee: Unassigned Created: 29/Mar/2023 03:24 AM Priority: Major Reporter: Thorsten Goetzke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6422e66... )
Cannot instantiate abstract class or interface : securiton.uls.domain.persist.link.impl.LinkPOSupport
at org.hibernate.metamodel.internal.EntityInstantiatorPojoStandard.instantiate(EntityInstantiatorPojoStandard.java:90) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:4292) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1467) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1451) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.instantiateEntity(AbstractEntityInitializer.java:673) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.resolveEntityInstance(AbstractEntityInitializer.java:666) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.resolveInstance(AbstractEntityInitializer.java:633) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.resolveEntityInstance(AbstractEntityInitializer.java:528) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.resolveInstance(AbstractEntityInitializer.java:403) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.internal.InitializersList.resolveInstances(InitializersList.java:87) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.internal.StandardRowReader.coordinateInitializers(StandardRowReader.java:110) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.internal.StandardRowReader.readRow(StandardRowReader.java:87) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:179) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:33) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:362) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:168) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.list(JdbcSelectExecutorStandardImpl.java:93) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:31) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.loader.ast.internal.SingleIdLoadPlan.load(SingleIdLoadPlan.java:144) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.loader.ast.internal.SingleIdLoadPlan.load(SingleIdLoadPlan.java:116) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl.load(SingleIdEntityLoaderStandardImpl.java:72) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.persister.entity.AbstractEntityPersister.doLoad(AbstractEntityPersister.java:3486) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3476) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:602) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromCacheOrDatasource(DefaultLoadEventListener.java:588) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:557) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:550) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:202) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:101) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:78) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:138) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.internal.SessionImpl.fireLoadNoChecks(SessionImpl.java:1231) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.internal.SessionImpl.immediateLoad(SessionImpl.java:1043) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:173) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:310) ~[hibernate-core-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
It seems like initializing a HibernateProxy for an abstract class currently throws an exception. Im currently not quite sure on the side conditions for this Exception to happen
( https://hibernate.atlassian.net/browse/HHH-16395#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16395#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100219- sha1:6a6077b )
1 year, 9 months
[JIRA] (HHH-16394) Statement Batch + Version + Dirty Collection leads to OptimisticLockException: Batch update returned unexpected row count from update
by Jones (JIRA)
Jones ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDdhZGVjN2Uz... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16394?atlOrigin=eyJpIjoiZDdhZG... ) HHH-16394 ( https://hibernate.atlassian.net/browse/HHH-16394?atlOrigin=eyJpIjoiZDdhZG... ) Statement Batch + Version + Dirty Collection leads to OptimisticLockException: Batch update returned unexpected row count from update ( https://hibernate.atlassian.net/browse/HHH-16394?atlOrigin=eyJpIjoiZDdhZG... )
Change By: Jones ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Given
* statement batch is enabled
* A versioned entity
* One managed instance of the versioned entity has dirty attributes
* Another managed instance of the versioned entity has a dirty collection
When
* flushing
Then
* OptimisticLockException: Batch update returned unexpected row count from update
{code:java}@Entity
@Table(name = "ENTITY_A")
public class EntityA {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
Integer id;
@Version
@Column(name = "VERSION")
long version;
@Column(name = "PROPERTY_A")
int propertyA;
@ManyToMany
@JoinTable(name = "ENTITY_A_TO_ENTITY_A", //
inverseJoinColumns = @JoinColumn(name = "SIDE_B"), //
joinColumns = @JoinColumn(name = "SIDE_A"))
final List<EntityA> owners = new ArrayList<>();{code}
{code:java} @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");
}
// Add your tests, using standard JUnit.
@Test
public void hhhXXXTest() throws Exception {
// BaseCoreFunctionalTestCase automatically creates the SessionFactory and
// provides the Session.
try (Session s = openSession()) {
Transaction tx = s.beginTransaction();
EntityA ownerA1 = new EntityA();
EntityA entityA1 = new EntityA();
EntityA ownerA2 = new EntityA();
EntityA entityA2 = new EntityA();
s.persist(ownerA1);
s.persist(ownerA2);
s.persist(entityA1);
s.persist(entityA2);
s.flush();
entityA1.propertyA = 1;
entityA2.owners.add(ownerA2);
tx.commit();
}
}{code}
{noformat}jakarta.persistence.OptimisticLockException: Batch update returned unexpected row count from update [1]; actual row count: 0; expected: 1; statement executed: update ENTITY_A set PROPERTY_A=?,VERSION=? where ID=? and VERSION=?
at org.hibernate.internal.ExceptionConverterImpl.wrapStaleStateException(ExceptionConverterImpl.java:216)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:93)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:168)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1416)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:485)
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2296)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1961)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:426)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:169)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:267)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
at org.hibernate.bugs.ORMUnitTestCase.hhhXXXXTest(ORMUnitTestCase.java:75)
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.hibernate.StaleStateException: Batch update returned unexpected row count from update [1]; actual row count: 0; expected: 1; statement executed: update ENTITY_A set PROPERTY_A=?,VERSION=? where ID=? and VERSION=?
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)
at org.hibernate.engine.jdbc.batch.internal.BatchImpl.checkRowCounts(BatchImpl.java:320)
at org.hibernate.engine.jdbc.batch.internal.BatchImpl.lambda$performExecution$2(BatchImpl.java:283)
at org.hibernate.engine.jdbc.mutation.internal.PreparedStatementGroupSingleTable.forEachStatement(PreparedStatementGroupSingleTable.java:59)
at org.hibernate.engine.jdbc.batch.internal.BatchImpl.performExecution(BatchImpl.java:265)
at org.hibernate.engine.jdbc.batch.internal.BatchImpl.addToBatch(BatchImpl.java:155)
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.doVersionUpdate(UpdateCoordinatorStandard.java:485)
at org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.handlePotentialImplicitForcedVersionIncrement(UpdateCoordinatorStandard.java:407)
at org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.coordinateUpdate(UpdateCoordinatorStandard.java:146)
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)
... 23 more
{noformat}
the failing test scenario to be is attached and also available here [https://github.com/ratoaq2/HHH-16394|https://github.com/ratoaq2/HHH-16394...]
( https://hibernate.atlassian.net/browse/HHH-16394#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16394#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100219- sha1:6a6077b )
1 year, 9 months