- 浏览: 230442 次
- 性别:
- 来自: 北京
-
文章分类
- 全部博客 (209)
- database (25)
- java技巧 (25)
- TC总结 (4)
- J2EE (8)
- 算法 (6)
- blog (4)
- php (4)
- linux & mac (19)
- 其它技术 (4)
- javascript&ajax (26)
- 测试技术 (8)
- XML&HTML (2)
- ORM (hibernate ...) (11)
- eclipse (5)
- 技术书籍 (8)
- 项目管理,cmmi (3)
- 硬件技术 (1)
- REST, web service, web架构 (1)
- 卓有成效程序员 (2)
- qone开发 (1)
- Design (4)
- .net (5)
- SCM (4)
- css (23)
- programming languages (1)
- ide (2)
- CSS Patterns (18)
- security (1)
- android (5)
最新评论
-
Virtoway:
说到Angular JS刚读到一片美国构架师的文章关于使用An ...
angular js: angular.bind example -
08284008:
该毛线啊,一点解释的都没有,怎么看
Thread join() 用法 -
Rex86lxw:
在eclipse中我一直用Navigator查看编写代码的,可 ...
eclipse不能自动编译,不报错 -
mistake:
..............
Angular js scope: the child scope would inherit from the parent scope -
sparrow1314:
very good! thanks!
IE下JS调试工具
Hibernate, Toplink Essentials, Openjpa, Eclipselink (jpa implementation compare)
- 博客分类:
- ORM (hibernate ...)
Summary
This article is a response to the lack of information on the net about the performance differences
among the 4 most well known Java Persistence API (JPA) implementations: Toplink Essentials
, EclipseLink
, Hibernate
and OpenJPA
.
Besides results and conclusions, the full test code
is also available in case you want to repeat the test yourself.
I wrote a relatively simple program which executes some queries and inserts in a MySQL
database through JPA. Four fixed-time tests were done with exactly the
same code, just changing the JPA implementation library and the
persistence.xml. I monitored the resources used by the JVM and counted
the inserts and queries executed during the tests. Finally, I show here
my conclusions and also the results of these tests, so that you can
draw your own. I consider the differences found among the different
implementations truly relevant.
For the tests performed for this article, nothing except JPA was used. No web pages, no web or application server. Just java threads, JPA and MySQL. I give more details in the next sections.
For the tests performed for this article, nothing except JPA was used. No web pages, no web or application server. Just java threads, JPA and MySQL. I give more details in the next sections.
Note
: In case you are using JPA with Axis and/or the Google Web Toolkit (GWT), this other article focused on working with JPA, Axis and GWT
could be of interest for you.
Description of hardware and software
The
tests have been done in an Acer Extensa 5620G laptop, with a pentium
Core 2 Duo T5250 Processor with 2 Gb Ram DDR2, being monitored by a
standard PC.
For the tests I have used the following software:
Inserting thread gets an arbitrary employee and makes a copy of him/her, letting MySQL generate a new emp_no. This was the only modification I did to the employees database: the emp_no is auto-generated.
Querying threads execute all these queries in sequence:
- Ubuntu 8.10 Intrepid Ibex
- MySQL database, version 5.0 (installed from the official Ubuntu repositories).
- Java Virtual Machine 1.6
- Driver jdbc for MySQL 5.1.
- Eclipse Ganymede
- The employees database example for MySQL, courtesy of Patrick Crews and Giuseppe Maxia (url below in the references section)
- JConsole for resources monitoring
- GIMP 2 to capture screens
The
database and the JVM were running in the Acer machine. But both
JConsole and GIMP were executed in a PC (also equiped with Ubuntu 8.10)
connected via tcp/ip to the test machine. I did it so that I did not
overload the machine running the tests.
Versions of the JPA implementations tested:
- Hibernate EntityManager and Annotations 3.4.0
- Toplink Essentials version 2 build 41
- Openjpa 1.2.0
- Eclipselink 1.0.2
Description of the code
The code developed for the tests is available to download here
. All you have to do is import the zip file in Eclipse
.
You will need at least one of the JPA implementation libraries. You can
download them from the urls in the references section below.
The code is made up of two type of threads, one for inserting and one for querying.Inserting thread gets an arbitrary employee and makes a copy of him/her, letting MySQL generate a new emp_no. This was the only modification I did to the employees database: the emp_no is auto-generated.
Querying threads execute all these queries in sequence:
- A query returning the number of female employees.
- A query returning the number of male employees.
- A query returning all employees hired since an arbitray date.
- A query returning all employees born after an arbitrary date.
- A query returning all women who have earned more than an arbitrary salary.
This is the starting sequence:
- When the program starts, it waits 2 minutes for the monitoring infraestructure to be ready (connecting JConsole to the JVM, basically).
- It then starts 2 of the so-called inserting threads. I start the inserting threads before the querying threads trying that the queries do not always return the same (which will eventually happen, anyway).
- After starting the inserting threads, the program starts running 18 of the querying threads, inserting a pause of 10 seconds before starting next. This is so that they do not execute the same query at the same time.
- The program runs the threads for 30 minutes. After that time, it sends a stop signal to the threads, which will safely make them stop after the next inserting or querying round. The main program waits 15 minutes for the threads to stop and the jvm memory to stabilize.
- Before stopping, the threads provide information about the number of inserts/queries they have executed.
The
only change from test to test was the JPA implementation library and
the persistence.xml. It is important to notice that the persistence.xml
was left by default for each of the implementations, omitting on
purpose any kind optimization that the implementation could accept.
Results
These were the results of the tests per JPA implementation library. Notice that the time was fixed: 30 minutes running.
Number of queries+inserts executed | Number of queries executed | Number of inserts executed | Max mem occupied during the test(Mb) | Mem occupied after the test(Mb) | |
OpenJPA |
3928
|
3530 | 398 | 96 |
61 |
Hibernate |
12687
|
3080 | 9607 | 130 | 79 |
Toplink Essentials |
5720
|
3740 | 1980 | 55 | 25 |
Eclipselink |
5874 |
3735 | 2139 | 57 | 25 |
The maximum memory occupied
is the maximum amount that the JVM reserved during the test.
The memory occupied after the test is the amount of memory that remained reserved after finishing the test.
I have emphasized the highest and lowest values for each of the columns.
The memory occupied after the test is the amount of memory that remained reserved after finishing the test.
I have emphasized the highest and lowest values for each of the columns.
You can see this graphically in the following images showing the data monitored during the different tests.


http://2.bp.blogspot.com/_VnVvmksSsVY/SXMNKB2YF4I/AAAAAAAAAKM/B13HTy_yq-Q/s1600-h/hibernate-complete.png
http://1.bp.blogspot.com/_VnVvmksSsVY/SXMNKrN1TuI/AAAAAAAAAKc/YGW3IPjy84U/s1600-h/toplink-complete.png
http://4.bp.blogspot.com/_VnVvmksSsVY/SXMNJg0AXSI/AAAAAAAAAKE/KJ2Ud70nyX8/s1600-h/eclipselink-complete.png
Conclusions
My intention is that anyone can draw their own conclusions looking at the results or using the code to do a test of their own.
Nevertheless, I consider that there are a number of conclusions that one can draw watching the monitored data:
Nevertheless, I consider that there are a number of conclusions that one can draw watching the monitored data:
- There is not an implementation that clearly has the best performance. Some had a very good CPU or memory performance and some did it very well when inserting or querying. But none of them was outstanding as a whole.
- The number of records inserted by Hibernate was extremely higher than it was for any other implementation (4 times more compared to Eclipselink and 24 times more compared to OpenJPA). However, Hibernate was also the JPA implementation that executed the lowest number of queries, although the differences in this value (3080 for Hibernate vs 3740 for Toplink Essentials) are not so extreme as for the number of inserts.
- Hibernate was also the implementation that consumed more memory. But having into account that it inserted many more records than the others, it sounds reasonable.
- OpenJPA had the lowest value of inserts+queries.
- The number of inserts executed by OpenJPA was extremely low, compared to the others.
- The usage of CPU in the case of Toplink Essentials and Eclipselink was extremely low.
Note for the JPA implementations responsible/developers
:
I am aware that some optimization can be obtained by changing the
persistence.xml and/or changing the code somehow. If you give me some
advice on how to improve the performance of any of the implementations,
I will be glad to update this post with that information.
References
Ubuntu: http://www.ubuntu.com/
Employees database: http://dev.mysql.com/doc/employee/en/employee.html , https://launchpad.net/test-db/
Openjpa: http://openjpa.apache.org/
Toplink Essentials: http://www.oracle.com/technology/products/ias/toplink/jpa/download.html
Hibernate JPA: http://www.hibernate.org/397.html
Eclipselink: http://www.eclipse.org/eclipselink/
MySQL: http://www.mysql.com/
Eclipse: http://www.eclipse.org/
References
Ubuntu: http://www.ubuntu.com/
Employees database: http://dev.mysql.com/doc/employee/en/employee.html , https://launchpad.net/test-db/
Openjpa: http://openjpa.apache.org/
Toplink Essentials: http://www.oracle.com/technology/products/ias/toplink/jpa/download.html
Hibernate JPA: http://www.hibernate.org/397.html
Eclipselink: http://www.eclipse.org/eclipselink/
MySQL: http://www.mysql.com/
Eclipse: http://www.eclipse.org/
Journal is from http://terrazadearavaca.blogspot.com/2008/12/jpa-implementations-comparison.html
发表评论
-
Use Fetch in NHibernate to solve N+1
2014-06-17 14:32 745http://bartwullems.blogspot ... -
(N)Hibernate inverse = true
2012-07-10 12:02 638http://www.mkyong.com/hib ... -
What happened behind "AllDeleteOrphan" mapping in NHibernate
2012-01-14 14:01 1317What happened behind "AllD ... -
Hibernate: Fetch plan and fetch strategy
2011-12-04 17:42 6301. Hibernate default to a lazy ... -
Active record: Transaction VS SessionScope
2011-11-28 23:00 751http://www.mail-archive.c ... -
How to use session per scope in Castle ActiveRecord
2011-11-26 22:50 594http://www.castleproject.org/ac ... -
hibernate使用sql query时单元测试跑了一部分后就不动了。
2009-04-13 16:27 1142我写了很多使用sql query ... -
org.hibernate.MappingException: No Dialect mapping
2009-03-30 10:58 1549http://www.w2tt.cn/redirect.php ... -
来自Java Persistence With Hibernate的示例
2009-02-04 12:13 7621. hibernate helloworld(pure hi ... -
hibernate-mapping-3.0.dtd
2009-01-11 22:42 2508<!-- Hibernate Mapping DTD. ...
相关推荐
5. **TopLink Essentials**:这是早期Java EE平台的一部分,后来演变为EclipseLink。它提供了JPA实现,同时还支持JAXB(Java Architecture for XML Binding),用于对象-XML的映射,为多层架构提供了全面的数据持久...
2. `toplink-essentials.jar`:Oracle的TopLink Essentials,也是JPA的一个实现,之前是开源版本,现在已被EclipseLink取代。 3. `jruby.jar`:JRuby,是Ruby语言的Java实现,允许在Java项目中使用Ruby代码。 4. `...
4. EclipseLink:作为Oracle公司的产品,EclipseLink是Toplink Essentials的继承者,它不仅支持JPA,还支持JDO(Java Data Objects)和其他持久性标准。EclipseLink提供了许多高级特性,如动态模型、缓存策略、...
c语言学习
人脸识别项目源码实战
人脸识别项目源码实战
本图书进销存管理系统管理员功能有个人中心,用户管理,图书类型管理,进货订单管理,商品退货管理,批销订单管理,图书信息管理,客户信息管理,供应商管理,库存分析管理,收入金额管理,应收金额管理,我的收藏管理。 用户功能有个人中心,图书类型管理,进货订单管理,商品退货管理,批销订单管理,图书信息管理,客户信息管理,供应商管理,库存分析管理,收入金额管理,应收金额管理。因而具有一定的实用性。 本站是一个B/S模式系统,采用Spring Boot框架,MYSQL数据库设计开发,充分保证系统的稳定性。系统具有界面清晰、操作简单,功能齐全的特点,使得图书进销存管理系统管理工作系统化、规范化。本系统的使用使管理人员从繁重的工作中解脱出来,实现无纸化办公,能够有效的提高图书进销存管理系统管理效率。 关键词:图书进销存管理系统;Spring Boot框架;MYSQL数据库
基于动态规划和模型预测控制的并联混合电动汽车最佳控制 简介:利用动态规划,使用模型预测控制,实现对并联混合动力电动汽车的最佳控制,并降低总体成本函数 使用动态规划可以实现混合动力电动汽车的优化控制 混合动力电动汽车的模型预测控制是通过使用动态规划在缩短的时域内实现的 代码为纯matlab脚本,附带说明电子文档 ,并联混合电动汽车; 动态规划; 模型预测控制; 最佳控制; 总体成本函数; Matlab脚本。,动态规划与模型预测控制在并联混合动力电动汽车的最优控制策略
人脸识别项目实战
2025 DeepSeek技术全景解析-重塑全球AI生态的中国力量.pdf
能够爬取非会员视频和音频资源,可通过ffmpeg等工具将视频资源和音频资源合并
基于差分进化算法DE的机器人路径规划 本产品基于优化的差分进化算法,专为机器人山地路径规划而设计 通过模拟差分进化过程中的变异、交叉与选择机制,算法能够智能探索并确定最优行进路线,全面考量路径长度、能量消耗及地形适应性 优化之处在于融合了动态差分权重与精英保留策略,显著增强了算法的搜索效率和求解质量,有效规避了早熟收敛的风险 该算法在山地这一复杂且多变的自然环境中展现出卓越性能,完美适配于机器人探险、山地救援、环境监测等多种应用场景 我们矢志为用户提供卓越、稳健的机器人路径规划方案,推动各类山地作业迈向更为精确与高效的路径规划新时代 ,差分进化算法DE; 机器人路径规划; 山地路径规划; 算法优化; 早熟收敛风险规避; 山地探险应用场景; 环境监测场景。,DE算法赋能机器人,优化山地路径规划方案
情侣游戏情侣飞行棋10元真心话大冒险情侣情趣骰子php源码 ----- 程序特色 ----- 1、完整的分销制度,可自定义多种不同的返佣比例 2、支持情侣飞行棋、情趣骰子,多种等级 3、无感微信自动授权登录,支持微信第三方授权登录 4、完全开源无加密
HeidiSQL的12.2.0.6576安装压缩包
监护人,小孩和玩具数据集 4647张原始图片 监护人 食物 孩子 玩具 精确率可达85.4% yolov5pytorch格式
本课程是 PHP 进阶系列之 Swoole 入门精讲,系统讲解 Swoole 在 PHP 高性能开发中的应用,涵盖 协程、异步编程、WebSocket、TCP/UDP 通信、任务投递、定时器等核心功能。通过理论解析和实战案例相结合,帮助开发者掌握 Swoole 的基本使用方法及其在高并发场景下的应用。 适用人群: 适合 有一定 PHP 基础的开发者、希望提升后端性能优化能力的工程师,以及 对高并发、异步编程感兴趣的学习者。 能学到什么: 掌握 Swoole 基础——理解 Swoole 的核心概念,如协程、异步编程、事件驱动等。 高并发处理——学习如何使用 Swoole 构建高并发的 Web 服务器、TCP/UDP 服务器。 实战项目经验——通过案例实践,掌握 Swoole 在 WebSocket、消息队列、微服务等场景的应用。 阅读建议: 建议先掌握 PHP 基础,了解 HTTP 服务器和并发处理相关概念。学习过程中,结合 官方文档和实际项目 进行实践,加深理解,逐步提升 Swoole 开发能力。
机器人先进视觉赛-基于深度学习yolov8的3D识别项目源码含gui界面(最新发布).zip 实现机器人的3D目标识别和分割功能 支持深度图像的处理和分析 【资源详情说明】 【1】该项目为近期精心打造开发,完整代码。同时,配套资料一应俱全,涵盖详细的设计文档 【2】项目上传前源码经过严格测试,在多种环境下均能稳定运行,功能完善且稳定运行,技术研究、教学演示还是项目实践,都能轻松复现,节省时间和精力。 【3】本项目面向计算机相关专业领域的各类人群,对于高校学生,可作为毕业设计、课程设计、日常作业的优质参考;对于科研工作者和行业从业者,可作为项目初期立项演示,助力快速搭建原型,验证思路。 【4】若具备一定技术基础,可在此代码上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 【5】小白,在配置环境或运行项目时遇到困难,可提供远程指导和全方位技术支持。 欢迎下载学习本项目资源,期待与你共同探讨技术问题,交流项目经验!
Matlab实现TSO-XGBoost多变量回归预测 Matlab实现TSO-XGBoost多变量回归预测,金枪鱼算法优化XGBoost多变量回归预测 1.data为数据集,7个输入特征,1个输出特征 2.MainTSO XGboost.m为主程序文件,其他为函数文件,无需运行 3.命令窗口输出R2、MAE、MAE和RMSEP等评价指标,可在下载区获取数据和程序内容 注意程序和数据放在一个文件夹,文件夹不可以XGBoost命名,因为有函数已经用过,运行环境为 Matlab2018及以上,预测效果如下 ,TSO-XGBoost; 多变量回归预测; Matlab实现; 金枪鱼算法优化; 评价指标; 预测效果; 文件夹结构; 运行环境,Matlab中TSO-XGBoost多变量回归预测优化实践
实时音视频SRT协议中文完整版
学习WiFi,入手资料