cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

persistenceService.run(upsert) caused Connection must not be in auto-commit mode

0 Likes
671

Hi Cap team,

Could you analyze when we execute an db statement using cap service in java as below:

@Autowired
PersistenceService persistenceService
CqnUpsert upsert = Upsert.into(GTTMetadataStatus_.class).entries(statusList);
persistenceService.run(upsert);

And when run above, it caused an error: Connection must not be in auto-commit mode

Do you know the reason, and how I can resolve this issue?

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Likes

marcbecker,

We did not use PlatformTransactionManager. We just use persistenceService.run(upsert);

And in application.yaml:

spring:
profiles: cloud
cds:
dataSource:
serviceName: ${TARGET_CONTAINER}
binding: ${TARGET_CONTAINER}

We use that. Do you know the reason?

yaowl
Discoverer
0 Likes
May I ask if you have solved this problem? I am encountering the same issue.
marcbecker
Product and Topic Expert
Product and Topic Expert
0 Likes

This usually happens in case CAP Java is not configured with the correct PlatformTransactionManager from Spring. Do you explicitly create (multiple) instances of PlatformTransactionManager in your application? If yes pleae make sure that the primary PlatformTransactionManager manages the primary DataSource, as those are the two instances that are used by CAP Java.

0 Likes

Do you mean this in spring config file?

cds:
dataSource:
serviceName: ${TARGET_CONTAINER}
binding: ${TARGET_CONTAINER}

Except this I have not seen any PlatformTransactionManager. Do you have an example for this?

marcbecker
Product and Topic Expert
Product and Topic Expert

No. Do you have usages of these classes in your project?

Do you have multiple datasource bindings? For example multiple HANA bindings? Or HANA bindings and service-manager bindings?