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
+32-8Lines changed: 32 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,27 +3,51 @@ Comparison of usage of non-JPA SQL mapping frameworks for Java (Jooq, Spring JDB
3
3
4
4
We are not comparing performance (that'll be maybe added later), but rather how are these frameworks used for everyday tasks.
5
5
6
-
We prepared some common scenarios, which you typically need to implement data-centric application, and then we implemented these scenarios using various non-JPA frameworks.
6
+
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.
7
+
8
+
## Frameworks compared
9
+
10
+
* Spring JDBCTemplate (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/jdbctemplate/JDBCDataRepositoryImpl.java))
11
+
* jOOQ (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/jooq/JooqDataRepositoryImpl.java))
12
+
13
+
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 do not know how to improve...
14
+
15
+
## Scenarios implemented
16
+
17
+
These are the scenarios:
18
+
1. Fetch single entity based on primary key
19
+
2. Fetch list of entities based on condition
20
+
3. Save new single entity and return primary key
21
+
4. Batch insert multiple entities of same type and return generated keys
22
+
5. Update single existing entity - update all fields of entity at once
23
+
6. Fetch entity and it's many-to-one relation (Company for Department)
24
+
7. Fetch entity and it's one-to-many relation (Departments for Company)
25
+
8. Update entities one-to-many relation - add two items, update two items and delete one item
26
+
9. Complex select - construct select where conditions based on some boolean conditions + throw in some joins
27
+
10. Call stored procedure/function and process results
28
+
11. Execute query using JDBC simple Statement (not PreparedStatement)
29
+
30
+
See javadoc of [Scenarios](src/main/java/com/clevergang/dbtests/Scenarios.java) class for description of each scenario.
7
31
8
32
## Model used
9
33
10
34

11
35
12
36
## Why only non-JPA?
13
-
Well, we were trying to "stick with standard" in our projects in the past, but after many years of JPA usage
14
-
(Hibernate mostly), we realized it's counterproductive. In most of our projects it caused more problems then
37
+
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
38
+
(Hibernate mostly), we realized it's counterproductive. In most of our projects it caused more problems than
15
39
it helped to solve - especially in big projects (with lots of tables and relations).
16
-
There are many reasons of those failures - but the biggest issues are that JPA implementations simply turned into bloatware,
17
-
lot of strange magic is happening inside and the complexity is so high, that you need a high-class Hibernate uberexpert
18
-
in every team so the app actually shows some performance and the code is managable...
40
+
There are many reasons of those failures - but the biggest issue is that JPA implementations simply turned into bloatware.
41
+
Lot of strange magic is happening inside and the complexity is so high, that you need a high-class Hibernate uberexpert
42
+
in every team so the app actually shows some performance and the code is manageable...
19
43
20
44
So we dropped JPA completely, started using JDBCTemplate and discovered that we can deliver apps sooner
21
-
(which was kind of surprising), they are god damn faster (thanks to effective use of DB) and much more robust...
45
+
(which was kind of surprising), they are a lot faster (thanks to effective use of DB) and much more robust...
46
+
This was really relaxing and we do not plan to return to JPA at all... (yes, even for CRUD applications!)
22
47
23
48
This project aims to explore other options in the SQL mapping area than just JDBCTemplate. It should serve us
24
49
- as point of reference when deciding for SQL mapping framework
25
50
- as a template of common DB usage scenarios
26
51
- to document best practices of such common usages (**comments are welcomed!**)
27
52
28
-
29
53
Use code in the repository as you like (MIT License)
0 commit comments