是否有可能使用@Transational在春天,的EclipseLink和放大器的工作; Tomcat的环境? [英] Is it possible to use @Transational worked in Spring, Eclipselink &Tomcat environment?

查看:520
本文介绍了是否有可能使用@Transational在春天,的EclipseLink和放大器的工作; Tomcat的环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HiAll,
我由的EclipseLink为Tomcat 文档困惑说:

局限性JPA:
  没有一个容器管理的持久性单元的@PersistenceContext注入可用 - 使用Persistence.createEntityManagerFactory(JTA_PU_NAME)

Limitations to JPA: No @PersistenceContext injection of a container managed persistence unit is available - use Persistence.createEntityManagerFactory(JTA_PU_NAME)

和,也被该<一个href=\"http://stackoverflow.com/questions/4049105/eclipselink-with-spring-cant-persist-into-db/4051527#4051527\">question&answer:

不过在Spring中典型的JPA配置看起来是这样的,所以你不需要手动创建的EntityManager:
  @PersistenceContext
  私人EntityManager的EM;

but the typical JPA configuration in Spring looks like this, so you don't need to create EntityManager manually : @PersistenceContext private EntityManager em;

所以,问题是:我可以使用这个注解@PersistenceContext的EntityManager的,以确保它会自动创建和我不需要手动创建它?

So, the question is: may I use this annotation @PersistenceContext for the entityManager to be sure that it will be created automatically and I dont need to create it manually?

目前我@Transactional注解不能正常工作,恐怕是因为手动创建实体管理器!

Currently my @Transactional annotation does not work properly and I'm afraid it is because of creating the entity manager manually!

请,需要帮助。

推荐答案

的EclipseLink文档中说, @PersistenceContext 是由Tomcat的自身没有处理。但是,如果你使用Spring, @PersistenceContext 是由Spring处理,这样就可以使用它。

EclipseLink documentation says that @PersistenceContext is not handled by Tomcat on its own. However, if you use Spring, @PersistenceContext is handled by Spring, so that you can use it.

参见:

  • 13.5 JPA

这篇关于是否有可能使用@Transational在春天,的EclipseLink和放大器的工作; Tomcat的环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆