Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
50b6f9da
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
50b6f9da
编写于
8月 16, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reference documentation covers async Hibernate/JPA bootstrap options
Issue: SPR-17189
上级
31c7807a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
59 addition
and
7 deletion
+59
-7
src/docs/asciidoc/data-access.adoc
src/docs/asciidoc/data-access.adoc
+59
-7
未找到文件。
src/docs/asciidoc/data-access.adoc
浏览文件 @
50b6f9da
...
...
@@ -311,8 +311,8 @@ The above definition of the `dataSource` bean uses the `<jndi-lookup/>` tag from
====
You can also use Hibernate local transactions easily, as shown in the following
examples. In this case, you need to define a Hibernate `LocalSessionFactoryBean`,
which
your application code will use to obtain Hibernate `Session` instances.
examples. In this case, you need to define a Hibernate `LocalSessionFactoryBean`,
which
your application code will use to obtain Hibernate `Session` instances.
The `DataSource` bean definition will be similar to the local JDBC example shown
previously and thus is not shown in the following example.
...
...
@@ -5116,8 +5116,8 @@ chapter will then cover the other ORM technologies, showing briefer examples the
====
As of Spring Framework 5.0, Spring requires Hibernate ORM 4.3 or later for JPA support
and even Hibernate ORM 5.0+ for programming against the native Hibernate Session API.
Note that the Hibernate team does not maintain any versions prior to 5.
0
anymore and
is likely to focus on 5.
2
+ exclusively soon.
Note that the Hibernate team does not maintain any versions prior to 5.
1
anymore and
is likely to focus on 5.
3
+ exclusively soon.
====
...
...
@@ -5175,8 +5175,25 @@ configuration:
----
You can also access a JNDI-located `SessionFactory`, using Spring's
`JndiObjectFactoryBean` / `<jee:jndi-lookup>` to retrieve and expose it. However, that
is typically not common outside of an EJB context.
`JndiObjectFactoryBean` / `<jee:jndi-lookup>` to retrieve and expose it.
However, that is typically not common outside of an EJB context.
[NOTE]
====
Spring also provides a `LocalSessionFactoryBuilder` variant, seamlessly integrating
with `@Bean` style configuration and programmatic setup (no `FactoryBean` involved).
Both `LocalSessionFactoryBean` and `LocalSessionFactoryBuilder` support background
bootstrapping, with Hibernate initialization running in parallel to the application
bootstrap thread on a given bootstrap executor (e.g. a `SimpleAsyncTaskExecutor`).
On `LocalSessionFactoryBean`, this is available through the "
bootstrapExecutor
"
property; on the programmatic `LocalSessionFactoryBuilder`, there is an overloaded
`buildSessionFactory` method which takes a bootstrap executor argument.
As of Spring Framework 5.1, such a native Hibernate setup can also expose a JPA
`EntityManagerFactory` for standard JPA interaction next to native Hibernate access.
See <<orm-jpa-hibernate,Native Hibernate setup for JPA>> for details.
====
[[orm-hibernate-straight]]
...
...
@@ -5781,7 +5798,7 @@ This is important especially when the hosting applications rely on different JPA
implementations because the JPA transformers are applied only at class loader level and
thus are isolated from each other.
[[orm-jpa-multiple]]
[[orm-jpa-
setup-
multiple]]
===== Dealing with multiple persistence units
For applications that rely on multiple persistence units locations, stored in various
...
...
@@ -5825,6 +5842,30 @@ affect __all__ hosted units, or programmatically, through the
`PersistenceUnitManager` is specified, one is created and used internally by
`LocalContainerEntityManagerFactoryBean`.
[[orm-jpa-setup-background]]
===== Background bootstrapping
`LocalContainerEntityManagerFactoryBean` supports background bootstrapping through
the `bootstrapExecutor` property:
[source,xml,indent=0]
[subs="
verbatim
,
quotes
"]
----
<bean id="
emf
" class="
org
.
springframework
.
orm
.
jpa
.
LocalContainerEntityManagerFactoryBean
">
<property name="
bootstrapExecutor
">
<bean class="
org
.
springframework
.
core
.
task
.
SimpleAsyncTaskExecutor
"/>
</property>
</bean>
----
The actual JPA provider bootstrapping will be handed off to the specified executor then,
running in parallel to the application bootstrap thread. The exposed `EntityManagerFactory`
proxy can be injected into other application components and is even able to respond
`EntityManagerFactoryInfo` configuration inspection. However, once the actual JPA provider
is being accessed by other components, e.g. calling `createEntityManager`, those calls
will block until the background bootstrapping has completed. In particular, when using
Spring Data JPA, make sure to set up deferred bootstrapping for its repositories as well.
[[orm-jpa-dao]]
==== Implementing DAOs based on JPA: EntityManagerFactory and EntityManager
...
...
@@ -6087,6 +6128,17 @@ as well as stronger optimizations for read-only transactions. Last but not least
native Hibernate setup can also be expressed through `LocalSessionFactoryBuilder`,
seamlessly integrating with `@Bean` style configuration (no `FactoryBean` involved).
[NOTE]
====
`LocalSessionFactoryBean` and `LocalSessionFactoryBuilder` support background
bootstrapping, just like the JPA `LocalContainerEntityManagerFactoryBean`.
See <<orm-jpa-setup-background,Background bootstrapping>> for an introduction.
On `LocalSessionFactoryBean`, this is available through the "
bootstrapExecutor
"
property; on the programmatic `LocalSessionFactoryBuilder`, there is an overloaded
`buildSessionFactory` method which takes a bootstrap executor argument.
====
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录