Я недавно провел некоторые тестирование громкости в приложении, и я заметил, что применение находится в состоянии замедляться во время транзакций с высокой объемом. Делая отладка, я заметил, что вставки не парят. Я столкнулся с той же проблемой, создающей минимальный воспроизводитель с нуля. База данных
testentity.java>package org.example;
import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.util.UUID;
@Entity
@Table(name = "TestEntity", schema = "testdb")
public class TestEntity extends PanacheEntityBase {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
@Column(name = "id")
private UUID id;
@Column(name = "testCol")
private final Integer testCol;
private TestEntity(final Builder builder) {
this.testCol = builder.testCol;
}
protected TestEntity() {
this.id = null;
this.testCol = null;
}
public UUID getId() {
return id;
}
public Integer getTestCol() {
return testCol;
}
public static final class Builder {
private Integer testCol;
public Builder testCol(final Integer testCol) {
this.testCol = testCol;
return this;
}
public TestEntity build() {
return new TestEntity(this);
}
}
}
testresource.java
package org.example;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
@Path("/test")
public class TestResource {
@POST
@Transactional
public Response hello() {
try {
List testEntities = new ArrayList();
for (int i = 0; i < 10; i++) {
testEntities.add(new TestEntity.Builder().testCol(i).build());
}
TestEntityRepository testEntityRepository = new TestEntityRepository();
testEntityRepository.persist(testEntities);
return Response.ok().build();
} catch (Exception e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
}
testentityRepository.java>package org.example;
import io.quarkus.hibernate.orm.panache.PanacheRepository;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.Optional;
import java.util.UUID;
@ApplicationScoped
public class TestEntityRepository implements PanacheRepository {
public Optional findById(final UUID id) {
return find("id", id).firstResultOptional();
}
}
В консоли Quarkus я получаю несколько идентичных операторов вставки, четко показывая, что нет пакетного.2025-07-02 15:20:59,929 DEBUG [org.hib.eng.jdb.spi.SqlStatementLogger] (executor-thread-2)
insert
into
testdb.TestEntity
(testCol, id)
values
(?, ?)
2025-07-02 15:20:59,930 DEBUG [org.hib.eng.jdb.spi.SqlStatementLogger] (executor-thread-2)
insert
into
testdb.TestEntity
(testCol, id)
values
(?, ?)
2025-07-02 15:20:59,930 DEBUG [org.hib.cac.int.TimestampsCacheEnabledImpl] (executor-thread-2) Pre-invalidating space [testdb.TestEntity], timestamp: 1751462519930
2025-07-02 15:20:59,932 DEBUG [org.hib.eng.jdb.bat.int.BatchImpl] (executor-thread-2) PreparedStatementDetails did not contain PreparedStatement on #releaseStatements : insert into testdb.TestEntity (testCol,id) values (?,?)
2025-07-02 15:20:59,933 DEBUG [org.hib.eng.tra.int.TransactionImpl] (executor-thread-2) On TransactionImpl creation, JpaCompliance#isJpaTransactionComplianceEnabled == false
2025-07-02 15:20:59,933 DEBUG [org.hib.res.jdb.int.LogicalConnectionManagedImpl] (executor-thread-2) Initiating JDBC connection release from beforeTransactionCompletion
2025-07-02 15:20:59,933 DEBUG [org.hib.eng.jdb.bat.int.BatchImpl] (executor-thread-2) PreparedStatementDetails did not contain PreparedStatement on #releaseStatements : insert into testdb.TestEntity (testCol,id) values (?,?)
2025-07-02 15:20:59,946 FINE [org.pos.jdb.PgConnection] (executor-thread-2) setAutoCommit = true
2025-07-02 15:20:59,947 DEBUG [org.hib.eng.jdb.bat.int.BatchImpl] (executor-thread-2) PreparedStatementDetails did not contain PreparedStatement on #releaseStatements : insert into testdb.TestEntity (testCol,id) values (?,?)
2025-07-02 15:20:59,947 DEBUG [org.hib.res.jdb.int.LogicalConnectionManagedImpl] (executor-thread-2) Initiating JDBC connection release from afterTransaction
2025-07-02 15:20:59,947 DEBUG [org.hib.cac.int.TimestampsCacheEnabledImpl] (executor-thread-2) Invalidating space [testdb.TestEntity], timestamp: 1751462459947
2025-07-02 15:20:59,948 DEBUG [org.hib.eng.jdb.int.JdbcCoordinatorImpl] (executor-thread-2) HHH000420: Closing un-released batch
2025-07-02 15:20:59,948 DEBUG [org.hib.eng.jdb.bat.int.BatchImpl] (executor-thread-2) PreparedStatementDetails did not contain PreparedStatement on #releaseStatements : insert into testdb.TestEntity (testCol,id) values (?,?)
2025-07-02 15:20:59,948 DEBUG [org.hib.eng.jdb.bat.int.BatchImpl] (executor-thread-2) PreparedStatementDetails did not contain PreparedStatement on #releaseStatements : insert into testdb.TestEntity (testCol,id) values (?,?)
< /code>
Вот некоторые приложения.quarkus.datasource.jdbc.transactions=enabled
quarkus.transaction-manager.default-transaction-timeout=6000 #high timeout for testing purposes
quarkus.hibernate-orm.jdbc.statement-batch-size=1000
quarkus.hibernate-orm.unsupported-properties."hibernate.order_inserts" = true
Подробнее здесь: https://stackoverflow.com/questions/796 ... ot-working
Quarkus hibernate orm panache - пакетные вставки не работают ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Почему findById возвращает устаревшие данные с помощью Hibernate Reactive и Panache?
Anonymous » » в форуме JAVA - 0 Ответы
- 20 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Почему findById возвращает устаревшие данные с помощью Hibernate Reactive и Panache?
Anonymous » » в форуме JAVA - 0 Ответы
- 15 Просмотры
-
Последнее сообщение Anonymous
-