Skip to content

spring data jdbc: saveAll on null id's entities calls update statement #2064

Open
@chrshnv

Description

@chrshnv

saveAll on null id's entities calls update statement.

List<AppConfiguration> configurationsToSave = List.of(accessTokenConfiguration, refreshTokenConfiguration, expiredAtConfiguration);

configurationsToSave.forEach(it -> log.info(it.getId() != null ? it.getId().toString() : null));

appConfigurationRepository
		.saveAll(List.of(accessTokenConfiguration, refreshTokenConfiguration, expiredAtConfiguration));

logs with saveAll:

2025-05-30T11:30:41.694+05:00  INFO 11461 --- [chats] [nio-8080-exec-1] r.t.o.c.service.impl.BitrixTokenService  : null
2025-05-30T11:30:41.694+05:00  INFO 11461 --- [chats] [nio-8080-exec-1] r.t.o.c.service.impl.BitrixTokenService  : null
2025-05-30T11:30:41.694+05:00  INFO 11461 --- [chats] [nio-8080-exec-1] r.t.o.c.service.impl.BitrixTokenService  : null
2025-05-30T11:30:41.724+05:00 ERROR 11461 --- [chats] [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.data.relational.core.conversion.DbActionExecutionException: Failed to execute DbAction.UpdateRoot(entity=ru.trek.ozon.chats.domain.AppConfiguration@658327e7)] with root cause

org.springframework.dao.IncorrectUpdateSemanticsDataAccessException: Failed to update entity [ru.trek.ozon.chats.domain.AppConfiguration@658327e7]; Id [2f0a0c62-1a97-4ca4-a8ba-2c4b501e2459] not found in database```

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions