Skip to content

Extend JpaExecutor.executeOutboundJpaOperationOnPersistentMode() so that it calls JpaOperations.deleteInBatch() when the payload is an Iterable #3614

@swiss-chris

Description

@swiss-chris

Expected Behavior

When I run the following code:

    .transform((p, h) -> p.getIterableOfPersistedEntities())
    .handle(Jpa.updatingGateway(entityManagerFactory).persistMode(DELETE))

I expect a bulk deletion of these entities that were read from my DB.

Current Behavior

When I run the code above, I get the following exception:

Caused by: java.lang.IllegalArgumentException: Unknown entity: java.util.ArrayList
	at org.hibernate.internal.SessionImpl.fireDelete(SessionImpl.java:910)
	at org.hibernate.internal.SessionImpl.delete(SessionImpl.java:836)
	at org.hibernate.internal.SessionImpl.remove(SessionImpl.java:3271)
	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.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:311)
	at com.sun.proxy.$Proxy115.remove(Unknown Source)
	at org.springframework.integration.jpa.core.DefaultJpaOperations.delete(DefaultJpaOperations.java:54)
	at org.springframework.integration.jpa.core.JpaExecutor.executeOutboundJpaOperationOnPersistentMode(JpaExecutor.java:456)

Context

As mentioned by @artembilan in this answer https://stackoverflow.com/a/68744857/349169, JpaExecutor.executeOutboundJpaOperationOnPersistentMode() could simply call JpaOperations.deleteInBatch() when the payload is an Iterable.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions