You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-11Lines changed: 19 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# Java persistence frameworks comparison
2
2
3
-
Comparison of usage of **non-JPA** SQL mapping (persistence) frameworks for Java (Jooq, Spring JDBCTemplate, MyBatis etc.).
3
+
Comparison of how **non-JPA** SQL mapping (persistence) frameworks for Java (Jooq, Spring JDBCTemplate, etc.) are used.
4
4
5
-
We are not comparing performance, but rather how are these frameworks used for everyday tasks.
5
+
I'm not comparing performance, but rather how are these frameworks used for everyday tasks.
6
6
7
-
We prepared some common scenarios, which you typically need to implement data-centric application, and then we implemented these scenarios using various non-JPA DB layer frameworks. This project should serve
7
+
I prepared some common scenarios, which you typically need to implement data-centric application, and then we implemented these scenarios using various non-JPA DB layer frameworks. This project should serve
8
8
- as point of reference when deciding for SQL mapping framework
9
9
- as a template of common framework usage scenarios (see scenarios below)
10
10
- to document best practices of such common usages (**comments are welcomed!**)
@@ -13,11 +13,21 @@ We prepared some common scenarios, which you typically need to implement data-ce
13
13
14
14
## Frameworks compared
15
15
16
-
* Spring JDBCTemplate (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/jdbctemplate/JDBCDataRepositoryImpl.java))
17
-
* jOOQ (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/jooq/JooqDataRepositoryImpl.java))
18
-
* MyBatis (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/mybatis/MyBatisDataRepositoryImpl.java) and [mapper](src/main/resources/mybatis/mappers/DataRepositoryMapper.xml))
16
+
I have following (subjectively evaluated :)) conditions on frameworks which I choose for consideration:
17
+
1. The framework should embrace - not hide - SQL language and RDBMS we are using
18
+
2. The framework must be mature enough for "enterprise level" use.
19
+
3. Can utilize JPA annotations, but must not be full JPA implementation (see "Why only non-JPA?" section below)
19
20
20
-
We tried to find optimal (== most readable) implementation in every framework, but comments are welcomed! There are lot of comments explaining why we chose to such implementation and some FIXMEs on places which we do not like, but which cannot be implemented differently or which we have troubles to improve...
21
+
With that conditions in respect, following frameworks were compared:
22
+
23
+
***Spring JDBCTemplate** (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/jdbctemplate/JDBCDataRepositoryImpl.java))
24
+
***jOOQ** (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/jooq/JooqDataRepositoryImpl.java))
25
+
***MyBatis** (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/mybatis/MyBatisDataRepositoryImpl.java) and [mapper](src/main/resources/mybatis/mappers/DataRepositoryMapper.xml))
26
+
27
+
I tried to find optimal (== most readable) implementation in every framework, but comments are welcomed! There are lot of comments in the code explaining why I chose such implementation and some FIXMEs on places which I do not like, but which cannot be implemented differently or which I have troubles to improve...
28
+
29
+
Furthermore, I considered (and tried to implement) even following frameworks, but it turned out they do not meet the conditions:
30
+
*[Speedment](https://github.com/speedment/speedment) - hides SQL language too much and tries to replace with stream operations; not all scenarios can be implemented in it; as of 11/30/2016 and version 3.0.1 the documentation on GitHub is very weak
21
31
22
32
## Scenarios implemented
23
33
@@ -51,17 +61,15 @@ Each scenario has it's implementation in the Scenarios class. See javadoc of [Sc
51
61
52
62
## Why only non-JPA?
53
63
54
-
Well, we were trying to "stick with standard" in our projects so we used JPA in the past, but after many years of JPA usage (Hibernate mostly), we realized it's counterproductive. In most of our projects it caused more problems than it helped to solve - especially in big projects (with lots of tables and relations). There are many reasons of those failures - but the biggest issue is that JPA implementations simply turned into bloatware. Lot of strange magic is happening inside and the complexity is so high, that you need a high-class Hibernate uberexpert in every team so the app actually shows some performance and the code is manageable...
64
+
Well, me and my colleagues were always trying to "stick with standard" in our projects so we used JPA in the past, but after many years of JPA usage (Hibernate mostly), we realized it's counterproductive. In most of our projects it caused more problems than it helped to solve - especially in big projects (with lots of tables and relations). There are many reasons of those failures - but the biggest issue is that JPA implementations simply turned into bloatware. Lot of strange magic is happening inside and the complexity is so high, that you need a high-class Hibernate uberexpert in every team so the app actually shows some performance and the code is manageable...
55
65
56
66
So we dropped JPA completely, started using JDBCTemplate and discovered that we can deliver apps sooner (which was kind of surprising), they are a lot faster (thanks to effective use of DB) and much more robust... This was really relaxing and we do not plan to return to JPA at all... (yes, even for CRUD applications!)
57
67
58
68
This project aims to explore other options in the SQL mapping area than just JDBCTemplate.
59
69
60
70
## Conclusions/Notes
61
71
62
-
I was able to implement all of the scenarios with all of the tested frameworks -
63
-
with only difference in how comfortable or inconvenient it was. Please note that following remarks
64
-
are very subjective and does not have to necessarily apply to you.
72
+
Please note that following remarks are very subjective and does not have to necessarily apply to you.
0 commit comments