N(N+1) Updates for each Insert

On Hibernate 6.4.4 and 6.4.9, I am observing the following odd behavior.

DB: 10.5.8-MariaDB MariaDB Server, using MariaDBDialect.

In a loop, I am doing the following:

for (loop control) {
  SomeObject object = new SomeObject(contents);
  repository.saveAndFlush(object);
  entityManager.detach(object);
}

At runtime, I am seeing the following in my log at each iteration of the loop:
First:

Hibernate: insert into some_object ...
Hibernate: update some_object set ...
Hibernate: update some_object set ...

Second:

Hibernate: insert into some_object ...
Hibernate: update some_object set ...
Hibernate: update some_object set ...
Hibernate: update some_object set ...
Hibernate: update some_object set ...

Third:

Hibernate: insert into some_object ...
Hibernate: update some_object set ...
Hibernate: update some_object set ...
Hibernate: update some_object set ...
Hibernate: update some_object set ...
Hibernate: update some_object set ...
Hibernate: update some_object set ...

And so on. By the 100th record, the process has slowed to a crawl. I understand that I might have better luck with saveAll, but at this time I have to do these in a loop. This issue happens if I do a save() rather than a saveAndFlush(), and also happens if I detach or not.

What could be causing this, and what’s the best way to approach a fix? Of note, the two updates per insert are livable; it’s the increasing updates for each turn that are the problem.

Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.