- 浏览: 544950 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (251)
- UML/RUP/软件工程 (0)
- DDD:领域驱动设计 (1)
- IaaS/Paas/SaaS (1)
- Hadoop/YARN (10)
- PBDP项目 (2)
- OSGi-基础 (7)
- OSGi-Aries (2)
- OSGi-SpringDM (32)
- Oracle/MySQL/SS (8)
- Felix/Equinox/Bnd (14)
- Virgo Server/Gemini (7)
- Weblogic/JBoss/Tomcat (10)
- ActiveMQ (14)
- Camel (1)
- Spring Roo/Eclipse (7)
- Java/JSP/JSF (10)
- Maven (19)
- ESB-Mule (1)
- ESB-ServiceMix (18)
- SOA/SCA/SDO (12)
- WebService/RESTful (17)
- JS/jQuery/ExtJS (4)
- Spring/JPA/MVC (15)
- SpringSecurity (5)
- BPM/jBPM (3)
- Hudson/SVN/CI (0)
- LinuxOS/虚拟化 (25)
- Office/OpenOffice (1)
- 项目管理 (5)
- POI/jFreeChart (1)
最新评论
-
panamera:
请问JMS Transport 发布的webservice 是 ...
CXF 提供的Service Transport-JMS Transpor -
jianyi296:
where is attachment.
CXF WebService Dynamic Client -
hj01kkk:
您好,我用jdbc-user-service为什么每次验证时都 ...
SpringSecurity笔记3-Authenticating Users:Authenticaton Strategy -
wufenglin1231:
你好,我在实现Mapping exceptions to re ...
RESTful 异常处理 -
xchd:
[echo] Project: common
[echo ...
Hive安装配置学习笔记
1. The open EntityManager in view pattern
使用Hibernate实现延迟加载时常见的异常:
org.hibernate.LazyInitializationException:
failed to lazily initialize a collection of role:
com.manning.sdmia.dataacces.domain.model.Contact.adresses,
no session or session was closed
With Spring, the lazy loading is tied to its resource management within its data access support.
According to the data access configuration, Spring is responsible for obtaining and releasing the
underlying resources of the JPA implementation. This implies that the scope of the resource
transparently changes. These are the impacts on resources scope in two use cases.
■ No transaction configured —Spring obtains an EntityManager instance before the call of every
JpaTemplate method and releases it after each call. EntityManager instances aren’t gathered and
every call uses a different EntityManager.
■ Transaction applied on service methods
—Spring obtains an EntityManager instance and uses it
for all the nested calls within the service method logic. The resource is obtained before the call of
every service method, stored in a variable of type ThreadLocal , and released when the service
method exits.
2. Using the open EntityManager in view pattern with Spring DM
Components using the open EntityManager in view pattern and data access components are
typically separated , because the former implement the UI of applications. Moreover, data access
components must make their EntityManagerFactory entities accessible as OSGi services so that
the user interface component can get at them。
Exporting the EntityManagerFactory bean as an OSGi service:
<bean id="entityManagerFactory" class="(...)">
(...)
</bean>
<osgi:service ref="entityManagerFactory"
interface="javax.persistence.EntityManagerFactory"/>
<osgi:reference id="entityManagerFactory" interface="javax.persistence.EntityManagerFactory"/>
web.xml中的配置:
<filter>
<filter-name>openEntityManagerInViewFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>openEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
You’ll notice that the filter is, by default, based on the EntityManagerFactory bean with the
identifier entityManagerFactory. This configuration can be changed with the
entityManagerFactoryBeanName filter initialization parameter. After performing this configuration,
your web application can lazily load data to build its views.
To summarize, the open EntityManager in view pattern provides a workable solution to using
lazy loading in JPA. This feature isn’t difficult to implement in an OSGi environment using Spring
DM, but it requires the sharing of EntityManagerFactory. Components using this pattern are
then tied to the underlying technology both through the service type and by the packages
needed in the manifest configuration.
发表评论
-
SpringDM笔记31-Testing with OSGi and SpringDM
2011-11-22 10:27 12441. 创建一个SpringDM测试类 SpringD ... -
SpringDM笔记30-OSGi中使用SSL/STL
2011-11-21 11:55 1317SSL:Secure Sockets Layer ... -
SpringDM笔记29-Require-Bundle与Import-Package的区别
2011-11-21 10:31 2238具体可参考:http://www.osgi.org/bl ... -
SpringDM笔记28-OSGi Bundle Activities with Spring-DM
2011-11-17 10:19 1158OSGi框架中也支持搞层次的模块交互:bundles.例如 ... -
SpringDM笔记28-Spring And OSGi:Layers of Integration
2011-11-15 11:00 11721. Application Design:Service和B ... -
SpringDM笔记27-Extending The Stand Extender and Configure
2011-09-02 09:38 8691. -
SpringDM笔记25-Using AJAX frameworks with Spring DM:GWT
2011-09-01 08:53 12001. Using Spring DM with AJAX fr ... -
SpringDM笔记24-Using action-based web frameworks with Spring DM:SpringMVC
2011-08-30 09:33 1478■ Action-based web frameworks ... -
SpringDM笔记22-Transactions Support With SpringDM
2011-08-29 21:24 12101. Spring’s transactional suppo ... -
SpringDM笔记21-Using ORM within OSGi with Spring DM
2011-08-25 10:31 2095Version 1.Object/relational ma ... -
SpringDM笔记20-Using JDBC within OSGi with Spring DM
2011-08-25 09:08 1775The public API for interact ... -
SpringDM笔记19-SpringDM如何处理OSGi应用的动态行为
2011-08-24 08:51 1142ServiceTracker 1. Dealing ... -
SpringDM笔记18-Designing OSGi Enterprise Applications
2011-08-22 11:08 11211. Organizing OSGi components ... -
SpringDM笔记17-Handling Collections of OSGi Services
2011-08-20 09:12 15411.Configuring collections:the l ... -
SpringDM笔记16-处理OSGi服务的动态性:事件
2011-08-19 09:51 17791. Service registration and unr ... -
SpringDM笔记15-通过声明特定的属性注册和引用服务
2011-08-18 11:01 14071. Configuration for registerin ... -
SpringDM笔记14-The thread context classloader 及在OSGi中的运用
2011-08-18 10:40 22471. Using the thread context cla ... -
SpringDM笔记13-OSGi服务注册与引用
2011-08-18 09:28 34491. Combining OSGi services and ... -
SpringDM笔记12-Spring DM’s web Extender运行机制
2011-08-17 11:04 2087SpringDM把一个WAR作为一个Bundle, 其实 ... -
SpringDM笔记11-Hard dependencies on the OSGi environment
2011-08-17 10:50 1413Any bean in a Spring DM app ...
相关推荐
hibernate-entitymanager.jar hibernate-entitymanager.jar
jpa--7.api(EntityManager其他方法)jpa--7.api(EntityManager其他方法)jpa--7.api(EntityManager其他方法)jpa--7.api(EntityManager其他方法)
jpa--6.api(EntityManager实体的状态)jpa--6.api(EntityManager实体的状态)jpa--6.api(EntityManager实体的状态)jpa--6.api(EntityManager实体的状态)
hibernate-entitymanager-5.5.6
Open EntityManager in View 29.4. Using H2’s Web Console 29.4.1. Changing the H2 Console’s Path 29.5. Using jOOQ 29.5.1. Code Generation 29.5.2. Using DSLContext 29.5.3. jOOQ SQL Dialect 29.5.4. ...
hibernate-entitymanager-3.4.0.GA.rar hibernate-entitymanager-3.4.0.GA.rar hibernate-entitymanager-3.4.0.GA.rar hibernate-entitymanager-3.4.0.GA.rar hibernate-entitymanager-3.4.0.GA.rar hibernate-...
hibernate-entitymanager-5.5.3.Final
hibernate EntityManager是围绕提供JPA编程接口的Hibernate Core的一个包装,支持JPA实体实例的生命周期,并允许你用标准的Java Persistence查询语言编写查询
hibernate-entitymanager-5.5.5.Final
hibernate-entitymanager-4.1.0.Final.jar
hibernate-entitymanager-3.2.jar.zip
hibernate-entitymanager-4.1.6.Final.jar
hibernate-entitymanager-3.3.1.GA hibernate-entitymanager-3.3.1.GA
开发jpa时用到的jar包,我在网上找了很久,没有免费的,所以就上传了一个,希望对大家有帮助
配置hibernate jpa所需jar包,为hibernate的entitymanager等提供支持
hibernate-entitymanager-4.0.0.Final.jar hibernate-jpa-2.0-api-1.0.1.Final.jar hibernate-validator-4.0.2.GA.jar httpclient-4.1.2.jar httpcore-4.1.2.jar jackson-core-asl-1.7.2.jar jackson-core-asl-1.9.9...
hibernate-entitymanager-4.3.11.Final.jar 这个是jpa的jar包