相关疑难解决方法(0)

更新我的实体时出现“ConcurrentModificationException”

问题

我使用 hibernate 5.4.11 核心,当我尝试更新大量实体时,我在这里遇到了这个问题。它看起来像一个休眠内部异常。

更新

我用hibernate 5.4.23测试了一下,也出现了同样的异常。我还将我的“mysql连接器”更新到最新版本“8.0.22”,但它也不起作用,同样的例外。

描述

这就是我更新实体的方式,它在另一个线程中运行,这不应该是这里的问题...它基本上是一个用于数据库操作的自己的线程,在该操作期间没有其他数据库操作正在运行。

        // 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)

java spring multithreading hibernate jpa

0
推荐指数
1
解决办法
2854
查看次数

标签 统计

hibernate ×1

java ×1

jpa ×1

multithreading ×1

spring ×1