Я недавно провел некоторые тестирование громкости в приложении, и я заметил, что применение находится в состоянии замедляться во время транзакций с высокой объемом. Делая отладка, я заметил, что вставки не парят. Я столкнулся с той же проблемой, создающей минимальный воспроизводитель с нуля. База данных
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
Программисты JAVA общаются здесь
-
Anonymous
1759333353
Anonymous
Я недавно провел некоторые тестирование громкости в приложении, и я заметил, что применение находится в состоянии замедляться во время транзакций с высокой объемом. Делая отладка, я заметил, что вставки не парят. Я столкнулся с той же проблемой, создающей минимальный воспроизводитель с нуля. База данных
[b] testentity.java[/b]>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);
}
}
}
[b]testresource.java[/b]
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();
}
}
}
[b] testentityRepository.java[/b]>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
Подробнее здесь: [url]https://stackoverflow.com/questions/79687527/quarkus-hibernate-orm-panache-batching-inserts-not-working[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия