JDBC中的EntityManger刷新模式

JDBC中的EntityManger刷新模式

本文介绍了JDBC中的EntityManger刷新模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JPA本质上是JDBC的更高抽象. EntityManager具有API setAutoFlushMode.可以将其设置为AUTO或COMMIT.用JDBC术语等效于什么?谢谢

JPA is essentially an higher abstraction of JDBC. EntityManager has an API setAutoFlushMode. It can be set to AUTO or COMMIT. What's th equivalent of this in JDBC terms?thanks

推荐答案

JDBC也具有自动提交功能.

JDBC has auto commit as well.

它们都用于配置库是否应自动提交到数据库.

They're both for configuring whether the library should automatically commit to the database.

JDBC的自动提交非常简单,它将立即将每个更新提交到数据库.如果没有自动提交,则只有在调用commit方法之后,更改才会提交.

JDBCs auto-commit is very simplistic, it will commit every update to the database immediately. Without auto-commit, changes aren't committed until the commit method is called.

JPA AUTO会在执行查询之前刷新数据库.像find这样的简单操作不需要刷新,因为该库可以处理搜索,但是查询要复杂得多,因此如果设置了AUTO,它将首先刷新它.如果将模式设置为COMMIT,则仅在调用提交或刷新时才将更改刷新到数据库.如果设置了COMMIT并运行了查询,它将不会返回尚未刷新的结果.

JPA AUTO causes a flush to the database before a query is executed. Simple operations like find don't require a flush since the library can handle the search, however queries would be much more complicated, and so if AUTO is set, it will flush it first. If the mode is set to COMMIT, it will only flush the changes to the database upon a call to commit or flush. If COMMIT is set, and a query is run, it will not return results that have not been flushed.

这篇关于JDBC中的EntityManger刷新模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 13:23