Caso práctico

spring3+hibernate4 service 中多线程事务异常及解决

初次使用spring3结合hibernate4做项目,迅速配置完成,测试,一切正常。

然而,当我在service层中另外开启一个线程,线程中的方法需要进行数据库操作,这个时候,悲催的抛出了异常:-org.hibernate.HibernateException: No Session found for current thread

当然,hibernate4的session是和当前线程绑定的,多线程中用sessionFactory.getCurrentSession()获取当前session自然不存在,不存在又不会自动创建,所以抛出了异常,无可厚非。

于是就想着怎么解决这个问题。

遍翻google、baidu,大部分都说如何如何配置,设置事务的传播属性propagation="REQUIRED",开启opensessioninview filter等等,无一对此问题有何解释(当然或许是我没翻到,有知道的麻烦告知)

在http://sishuok.com/forum/blogPost/list/2625.html#7523上看到相关配置,我就想作者这个项目该多线程运行正常吧,果断下载源码,修改测试,oh。。。跟我的错一模一样!

IdentityMine 公司的 Evan Lang 介绍基于一体机开发的空中曲棍球游戏

下载视频

1280X720 (89.49 MB)

IdentityMine 公司的 Evan Lang 介绍基于一体机开发的空中曲棍球游戏,包括对便携式一体机所需的应用开发流程所做的特殊更改。

  • Microsoft Windows* 8.x
  • Windows*
  • 案例研究
  • Sensores
  • Interfaces de Touch
  • Case Study: Implementing Intel® x86 Support for Android* with CRI Middleware

    Android* devices powered by the Intel® Atom™ processor are rising in popularity, and supporting applications are being released continuously. To meet the needs of application developers focused on creating games for Android devices with Intel Atom processors, middleware companies began supporting x86. One such company, CRI Middleware Co., Ltd., offers runtime library x86 support for Android middleware. It has done this by changing the build settings of the makefile in the Android NDK and replacing the ARM* NEON* instructions. Included in x86 support of the middleware runtime library for Android devices is a plug-in for Unity*, a game engine developed by Unity Technologies, which allows developers to build games by simply setting the x86 folder as the build target with the Android NDK.
  • Desarrolladores
  • Socios
  • Android*
  • Android*
  • Desarrollo de juegos
  • Desarrollo de juegos
  • Migración
  • Project Newton - Total Solution for Smart Home IoT Control

    Project Newton includes the connection of all main platforms (Intel® Core™ processor, Intel® Centrino* processor technology, Intel® Atom™ processor, ARM* mobile platforms) and all IoT platforms (Intel® Edison board, Intel® Galileo board, Raspberry*, Spark*, Mbed*, Freescale*, Arduino Uno*, etc.). Thus, Project Newton can connect platforms running all current mainstream OSs (Windows*, Linux*, Android*) and NonUI-OSs (Mbed*, Contiki*, RIOT*, Spark*, OpenWRT*, Yocto*, WindRiver*, VxWorks*, Raspbian*, etc.) in real time We use CoAP (Constrained Application Protocol), which is a software protocol intended to allow simple electronics devices to communicate interactively over the Internet. CoAP protocol, based on the RESTful framework, is converted into an HTTP protocol to build a smart gateway easily.
  • Desarrolladores
  • Android*
  • Arduino
  • Android*
  • Internet de las cosas
  • Procesadores Intel® Atom™
  • Internet de las cosas
  • Игра Beatbuddy от инди-разработчика движется вперед с новыми технологиями

    Введение

    Каким образом небольшая компания-разработчик игр остается на гребне волны и расширяет свой рынок? Давайте взглянем на инди-разработчика, компанию Threaks, выигравшую множество наград и создавшую BeatBuddy. Беседа с CEO студии, Вольфом Лэнгом, раскроет секреты их непростого пути в мир разработки игр.

    От студенческого до инди-проекта

  • Desarrolladores
  • Socios
  • Estudiantes
  • Android*
  • Apple iOS*
  • Microsoft Windows* 8.x
  • Android*
  • Desarrollo de juegos
  • UX
  • Windows*
  • Unidad
  • Beatbuddy
  • Threaks
  • th3aks
  • 2-in-1
  • unity
  • slate
  • indy
  • Desarrollo de juegos
  • Migración
  • Interfaces de Touch
  • Experiencia del usuario y diseño
  • ANSYS* Scales Simulation Performance

    The Need for Speed in Simulation-Based Design

    Engineering simulation software has changed how companies design products, enabling them to explore and test more design options faster, while reducing the need for physical prototyping. ANSYS software has played a central role in this transition and is now used by 96 of the top 100 industrial companies on the FORTUNE 500* list.

  • Desarrolladores
  • Profesores
  • Estudiantes
  • Intel® Math Kernel Library
  • Ansys Mechanical
  • Modernización de código
  • Arquitectura Intel® para muchos núcleos integrados
  • Subprocesos
  • ANSYS* 助力扩展仿真性能

    基于仿真的设计需要出色的速度

    设计仿真软件改变了企业设计产品的方式,企业不仅能够更加快速地了解和测试更多设计选项,还能减少对物理样机的需求。 ANSYS 软件在这种转变中发挥了核心作用,目前,财富 500 强企业的前 100 家工业公司中,有 96 家采用了该软件。

    ANSYS* 客户对更高计算性能的需求永无止境,以通过更高的保真度建模和测试大型程序集。 一些客户还希望通过集成其他物理变量、了解非线性和复合材料,以及评估复杂程度更高的动态环境状况,借助每一次仿真获取更加深入的洞察。 但是,快速获取结果仍然是大多数客户满足迫切的上市时间需求的关键因素。 随着仿真规模和复杂性的不断增加,计算平台的速度和容量的提升也必须与此保持同步。

    查看完整的 ANSYS 案例研究

  • Desarrolladores
  • Profesores
  • Estudiantes
  • Intel® Math Kernel Library
  • Ansys Mechanical
  • Modernización de código
  • Arquitectura Intel® para muchos núcleos integrados
  • Subprocesos
  • Performance of Multibuffer AES-CBC on Intel® Xeon® Processors E5 v3

    This paper examines the impact of the multibuffer enhancements to OpenSSL* on the Intel® Xeon® processor E5 v3 family when performing AES block encryption in CBC mode. It focuses on the performance gains seen by the Apache* web server when managing a large number of simultaneous HTTPS requests using the AES128-SHA and AES128-SHA256 ciphers, and how they stack up against the more modern AES128-GCM-SHA256 cipher.

  • Linux*
  • Servidor
  • Intermedio
  • OpenSSL
  • Intel® Xeon® Processor
  • Apache*
  • CBC
  • AES128
  • Seguridad
  • Suscribirse a Caso práctico