我使用 hibernate 5.4.11 核心,当我尝试更新大量实体时,我在这里遇到了这个问题。它看起来像一个休眠内部异常。
这就是我更新实体的方式,它在另一个线程中运行,这不应该是这里的问题...它基本上是一个用于数据库操作的自己的线程,在该操作期间没有其他数据库操作正在运行。
// Run the database operation for updating the entities async in a new thread, return updated entities once done
return CompletableFuture.runAsync(() -> {
var session = database.openSession();
session.beginTransaction();
try {
// Save identities first
for (var identity : identities)
session.update(identity);
// Update components, each component-type
for(var insertedClass : insertationOrder)
for (var hbc : componentsPerType.get(insertedClass))
session.update(hbc);
session.flush();
session.clear();
session.getTransaction().commit();
} catch (Exception e){
var messageComposer = new ExceptionMessageComposer(e);
GameExtension.getInstance().trace("Update : "+messageComposer.toString()); …Run Code Online (Sandbox Code Playgroud)